The psql client provides a command-line connection to PostgreSQL. You can use it to inspect a database or run authorised SQL queries when the client and database access are available.

Connect to the intended database

From a terminal with psql installed, run:

psql -h database-host -U database-user -d database-name -W

Replace the three placeholders. -W asks for the password; do not put it in the command. Use the provider’s approved connection and TLS settings. If you omit the host, the client may use a local socket rather than the server you intended.

After connecting, check:

\conninfo

This shows the active connection details. SSH may provide access to a suitable terminal, but an SSH login alone does not grant database permissions.

Use psql help

CommandPurpose
\?Help for psql commands
\hHelp for SQL commands
\dtList tables visible through the current search path
\zList access privileges for database objects
\qExit psql

SQL statements usually end with a semicolon. Review the effect of any data-changing statement before running it.