Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

Connect to Postgres Databases With psql

The default way to connect to post gres is:

Code

psql postgres

which connects to the postgres database as the current user you're runnig on the command line

To connect to a specific database as a specific user (aka role), use:

Code

psql -U user_name -d database_name

To connect to the root database with the root user, do this:

Code

psql -U postgres