PostgreSQL is an open source object-relational database system. It is one of leading database server used for production servers. This tutorial will help you to install PostgreSQL database server on Debian 8 and Debian 7 systems.
Step 1. Configure Apt Repository
First, you need to import PostgreSQL packages signing key on your system. Use the below command to import key.
$ wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add -
Now add PostgreSQL apt repository in your system as per your operating system. These are suggested on official PostgreSQL website using following command.
Debian 8 (Jessie)
$ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ jessie-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
Debian 7 (Wheezy)
$ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
Step 2. Install PostgreSQL Server
At this stage, you have successfully added PostgreSQL official repository in your system. Now update repository list. After that install Latest PostgreSQL Server in our Ubuntu system using following commands.
$ sudo apt-get update $ sudo apt-get install postgresql postgresql-contrib
Step 3. 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 the same name ‘postgres’. So to connect to postgres server, login 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.
To disconnect from PostgreSQL database command prompt just type below command and press enter. It will return you back to Ubuntu command prompt.
Your PostgreSQL installation has been completed successfully. Let’s move to phpPgAdmin installation of Ubuntu systems.