Install Postgresql On Centos 6.5 Via-Yum

Installing PostgreSQL on a Centos 6.5 is as simple as "yum install postgresql" but you're probably here because you want to install a newer version of PostgreSQL and also want more information on how to configure it. I Do not use the stock postgresql myself. I always want the latest. Centos 6.X ships with postgresql 8.4.13 but postgresql 9.x has been out for a while now. So In this howto, we are going to be installing Postgresql 9.3.

Add the PostGres Yum repository

rpm -Uvh http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-redhat93-9.3-1.noarch.rpm

Install PostgreSQL Server

Since we added the postgres repo, we can now install rpms' from it. Use following command to install PostgreSQL on your system with yum package manager.

# yum install postgresql93-server postgresql93

If you are going to be using python's psycopg2 then you will also probably need the devel.

yum install postgresql93-devel

Initialize PGDATA

After installing PostgreSQL server, It’s required to initialize it before using first time. To initialize database use below command.

# /etc/init.d/postgresql-9.3 initdb

In some cases above commands doesn't work, Then use following command.

# /usr/pgsql-9.3/bin/postgresql93-setup initdb

Above command will take some time to initialize PostgreSQL first time. PGDATA environment variable contains path of data directory.
PostgreSQL data directory Path: /var/lib/pgsql/9.3/data/

Start PostgreSQL Server

Start PostgreSQL service using following command.

# service postgresql-9.3 start

Setup PostgreSQL service to auto start on system boot.

# chkconfig postgresql-9.3 on

Verify PostgreSQL Installation

After completing step 4, we have installed postgres 9.3 on server, Let do a basic test to verify that installation completed successfully. To verify switch to postgres user.

# su - postgres

Use psql command to access PostgreSQL prompt with admin privileges.

$ psql

psql (9.3.1)
Type "help" for help.

postgres=#

Congratulation’s! You have successfully installed PostgreSQL Server. Read below article to install phpPgAdmin.

Install phpPgAdmin on Centos 7 . The title says Centos 7 but it is exactly applicable to Centos 6