PostgreSQL is an open source object-relational database system. It is one of leading database server used for production servers. PostgreSQL allows us to execute stored procedures in various programming languages, like PHP, C/C++, Python, Java, Perl, Ruby and its own PL/pgSQL, which is similar to Oracle’s PL/SQL.

Postgres database is used the persistent store of data

Install Postgres

  • yum install postgres 

     (Note : remember the password for the postgres user – you need it later)

  1. sudo apt-get update
  2. sudo apt-get upgrade
  3. sudo apt-get install postgresql-9.6

Setting up Postgres

  1. Launch pgAdmin.
  2. Connect to the local server.  Use localhost for the server name, postgres for the username and the password you used when you installed Postgres.

You need to be root to perform this command.Note: If you did not set password during installation (sudo apt-get install postgresql), then you can set it as follows:


sudo -u postgres psql postgres

On the postgres client prompt, use the following command to set the password.

alter user postgres with password 'postgres';

Connect to PostgreSQL
After installing PostgreSQL database server, by default,, it creates a user ‘postgres’ with role ‘postgres’. It also creates a system account with same name ‘postgres’. So to connect to postgres server, log in to your system as user postgres and connect database.

$ sudo su - postgres
 $ psql
Now you are logged in to PostgreSQL database server. To check login info use following command from database command prompt.
postgres-# \conninfo

To disconnect from PostgreSQL database command prompt just type below command and press enter. It will return you back to Ubuntu command prompt.

postgres-# \q