How to Install PostgreSQL 9.3 on CentOS/RHEL and Fedora

Managed VPS Server $7/mo

Pre-installed PostgreSQL 9x + free control panel

PostgreSQL is a open source object-relational, highly scalable, SQL compliant database management system. PostgreSQL is developed at the University of California at Berkeley Computer Science Department. This article will help you for installing PostgreSQL on CentOS, RHEL and Fedora Systems.

Step 1: Add PostgreSQL Yum Repository

First step is to install postgres repository in your system, Use one of below commands as per your system architecture and operating system.

CentOS/RHEL 5, 32-Bit:
# rpm -Uvh http://yum.postgresql.org/9.3/redhat/rhel-5-i386/pgdg-centos93-9.3-1.noarch.rpm

CentOS/RHEL 5, 64-Bit:
# rpm -Uvh http://yum.postgresql.org/9.3/redhat/rhel-5-x86_64/pgdg-centos93-9.3-1.noarch.rpm

CentOS/RHEL 6, 32-Bit:
# rpm -Uvh http://yum.postgresql.org/9.3/redhat/rhel-6-i386/pgdg-redhat93-9.3-1.noarch.rpm

CentOS/RHEL 6, 64-Bit:
# rpm -Uvh http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-redhat93-9.3-1.noarch.rpm

Fedora 19, 64-Bit:
# rpm -Uvh http://yum.postgresql.org/9.3/fedora/fedora-19-x86_64/pgdg-fedora93-9.3-1.noarch.rpm

Fedora 18, 64-Bit:
# rpm -Uvh http://yum.postgresql.org/9.3/fedora/fedora-18-x86_64/pgdg-fedora93-9.3-1.noarch.rpm

Fedora 18, 32-Bit:
# rpm -Uvh http://yum.postgresql.org/9.3/fedora/fedora-18-i386/pgdg-fedora93-9.3-1.noarch.rpm

 
Step 2: Install PostgreSQL Server

Use following command to install PostgreSQL on your system with yum package manager.

# yum install postgresql93-server postgresql93

Step 3: 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/

Step 4: 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

Step 5: 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.

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

 

Check out our VPS packages today. Our VPS server management will cover this for you.

source: http://tecadmin.net/install-postgresql-on-centos-rhel-and-fedora/

January 4, 2015   5291    Linux  
Total 14 Votes:
2

Tell us how can we improve this post?

+ = Verify Human or Spambot ?


Leave a Comment