In this tutorial we will cover the steps needed to install PostgreSQL on your CentOS 6.4, Debian or Ubuntu platform.

Requirements

  • CentOS 6.4, Debian or Ubuntu installed on your computer/server
  • SSH access (Command line access to the server)
  • root privileges
  • Basic skills for working on a Linux environment

PostgreSQL is powerful and popular free open-source database management system which uses the SQL language. It fully supports foreign keys, joins, views, triggers, and stored procedures (in multiple languages).

Install PostgreSQL

In order to install the PostgreSQL service we will use the default package manager included inside the corresponding Linux distribution:

CentOS 6.4

install the service:

and initialize the database environment:

Debian/Ubuntu

sudo apt-get install postgresql postgresql-contrib

You will be prompted to confirm the installation. During the process additional packages required by the PostgreSQL service can be installed as well.

Test the functionality of the PostgreSQL service

By default, PostgreSQL creates a user and a database called postgres. After the installation you should be able to access the service using that username:

The command prompt will be switched and you will be able to use the psql command:

The command prompt will be switched again to something similar to:

Here is list of some of the available commands:

In order to be able to access the PostgreSQL server from remote computer you should make sure that the default PostgreSQL port 5432 is allowed inside the server's firewall:

Start Up PostgreSQL automatically on server boot

In order for the service to start automatically upon server boot up you can execute the following command:

CentOS 6.4

Debian/Ubuntu