home ~ projects ~ socials

Connect to Postgres Databases With psql

The default way to connect to post gres is:

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:

psql -U user_name -d database_name

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

psql -U postgres
-- end of line --