Logging in to PostgreSQL database on Linux terminal

This section assumes command line access to the PostgreSQL server from a terminal window. The server used in this section is running Ubuntu Linux 18.10.

To Log into your user account in the database:

psql -U <postgre username> -d <dbname>

Logging in to root PostgreSQL user account

If you are the database administrator and need access to the root PostgreSQL user account, the method is slightly different.

At the terminal window:

sudo -i -u postgres

Logging into the database cluster and database

Once logged in as postgres, it is possible to log into the PostgreSQL database cluster and connect to your database to make alterations as needed.

  1. Type “psql” into the terminal
  2. Type “\connect <databasename>” into the sql prompt

 

Posted in Instructional Information.