PostgreSQL 9.5 Released. PostgreSQL is an 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 show you how to install PostgreSQL on CentOS7, RHEL7.

Adding PostgreSQL Yum Repository

More info about PostgreSQL repository package for various operating systems,  visit PostgreSQL repositories

Use one of below commands as per your system architecture and operating system.

# yum -Uvh
CentOS 7 # rpm -Uvh
Installing PostgreSQL Server

The yum repo file /etc/yum.repos.d/pg-9.repo looks like this:

name=PostgreSQL 9.5 $releasever - $basearch

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

# yum install postgresql95-server postgresql95
Initializing PGDATA

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

# /usr/pgsql-9.5/bin/postgresql95-setup initdb

Above command will take some time to initialize PostgreSQL first time. PGDATA environment variable contains the path of data directory.

PostgreSQL data directory Path: 

You can make a symbolic to the dedicated database filesystem/devices(SSD etc..)
mv /var/lib/pgsql/9.5/data/ /database/pg95
ln -s /database/pg95 /var/lib/pgsql/9.5/data
Start PostgreSQL Server

To start PostgreSQL service using following command as per your operating systems. Also enable PostgreSQL service to auto start on system boot.

For CentOS/RHEL 7 and Fedora 23

# systemctl start postgresql-9.5
# systemctl enable postgresql-9.5

On other OS for example CentOS/RHEL 6/5 and Fedora 22/21

# service  postgresql-9.5 start
# chkconfig postgresql-9.5 on
Verify PostgreSQL Installation

After completing above steps, you have installed PostgreSQL 9.5 on your server, Let’s login to postfix to verify that installation completed successfully.

# su - postgres

Use psql command to access PostgreSQL prompt with admin privileges.

$ psql
psql (9.5.0)
Type "help" for help.


You may create password for user postgres for security purpose.

postgres=# password postgres

All done !


Comments powered by CComment