What to do when you can’t connect to your database using a graphical interface?
Using PSQL, you can connect to your database if you have a connection to the server through a command line interface.
PSQL can connect in multiple ways, either by specifying each individual aspect of the connection or, for an easier solution, by providing the URI.
$ psql postgresql://<username>@<server>:<port>/<dbname>
Using PSQL, you can do a lot through the backend, like defining variables to be used in queries later, check the sizes of your databases, execute DDLs generated through other queries, etc. …
A lot of the PSQL specific commands, are using the underlying pg_catalog.
To create queries on the catalog ourselves can be hectic as there is a lot of information in there, but PSQL can help us here.
By setting some variables, we can see the queries behind the specifics commands issues by PSQL.
<dbname>=$ \set ECHO_HIDDEN on
As you can see, PSQL is a powerful tool, but it takes some time to master.
For further reading about PSQL, head to https://psql-tips.org