How to Install PostgreSQL 11 on CentOS/RHEL 7/6

0

PostgreSQL 11 Released. It 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 will help you to install PostgreSQL 11 on CentOS/RHEL 7/6 system.

This article has been tested on CentOS Linux release 7.4.1708.

Download CentOS 7

Step 1 – Configure Yum Repository

Firstly you need to configure the PostgreSQL repository in your system. Use one of the below commands as per your operating system version.

## CentOS/RHEL - 7
rpm -Uvh https://yum.postgresql.org/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm

## CentOS/RHEL - 6
rpm -Uvh https://yum.postgresql.org/11/redhat/rhel-6-x86_64/pgdg-centos11-11-2.noarch.rpm

For more details visit PostgreSQL repositories link page where you can get repository package rpm for various operating systems.

Step 2 – Install PostgreSQL 11 on CentOS

After enabling PostgreSQL yum repository in your system use following command to install PostgreSQL 11 on your system with yum package manager.

yum install postgresql11-server

This will also install some additional required packages on your system. Enter y to confirm and complete the installation process.

Install PostgreSQL 11 on CentOS

Step 3 – Initialize PGDATA

After that, you need to initialize the PostgreSQL instance. In other words, this will create data directory and other configuration files on your system. To initialize database use below command.

/usr/pgsql-11/bin/postgresql-11-setup initdb

Initialize PostgreSQL 11 on CentOS

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

PostgreSQL 11 data directory Path: /var/lib/pgsql/11/data/

Setp 4 – Start PostgreSQL Server

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

CentOS/RHEL – 7

systemctl enable postgresql-11.service
systemctl start postgresql-11.service

CentOS/RHEL – 6

service postgresql-11 start
chkconfig postgresql-11 on

Step 5 – Verify PostgreSQL Installation

After completing the above all steps. Your PostgreSQL 11 server is ready to use. Log in to postfix instance to verify the connection.

su - postgres -c "psql"

psql (11.0)
Type "help" for help.

postgres=# 

You may create a password for user postgres for security purpose.

postgres=# \password postgres

In conclusion, You have successfully installed the PostgreSQL database server on CentOS/RHEL 7/6 system.

0/5 (0 Reviews)

Leave A Reply

Your email address will not be published.