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 -WReplace 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:
\conninfoThis 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
| Command | Purpose |
|---|---|
\? | Help for psql commands |
\h | Help for SQL commands |
\dt | List tables visible through the current search path |
\z | List access privileges for database objects |
\q | Exit psql |
SQL statements usually end with a semicolon. Review the effect of any data-changing statement before running it.