Easy way to install PostgreSQL on CentOS

PostgreSQL or Postgres, is a very powerful, highly scalable relational database system, that peovided implementation of SQL query language. It is open source & can be installed on Unix/Linux system as well as on Windows systems. It is a popular choice for small & large organizations alike. In this tutorial, we will learn to install PostgreSQL on CentOS (& other REDHAT based distributions).

Recommended Read : MongoDB installation & configuration on RHEL/CentOS

Also Read : Installing & Configuring MariaDB on RHEL/CentOS

Install PostgreSQL

We can easily install PostgreSQL with the default package manager in CentOS i.e. yum. We will be discuss how we can install PostgreSQL with yum using,

1- Default repositories
2- Official PostgreSQL reposiories

1- Install PostgreSQL using default yum repositories

Default repositories of the CentOS server contains the packages for postgres & we can install then with the following command,

# yum install postgresql-server postgresql-contrib -y

Now after the packages have been installed, we need to initialize the DB to use it first time. For that we will use the following command,

# postgresql-setup initdb

Now start the database service & enable it for boot time,

# systemctl start postgresql
# systemctl enable postgresql

Now the downside for installing with this method is that we will not get the latest version of postgres (this will provide version 9.2) If we need to install the latest stable version of postgres, which at the time of writing this tutorial is PostgreSQL 10, than we need to install PostgreSQL using the official repositories.

2- Install PostgreSQL using the official repository

For this method, we will firstly add the official repo for Postgres on our system with the following command,

# yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm

Now we will install PostgreSQL,

# yum install postgresql10-server postgresql10

Next step is to initialize the database, same as we did above,

# /usr/pgsql-10/bin/postgresql-10-setup initdb

& than start the service & enable it for boot time,

# systemctl start postgresql-10
# systemctl enable postgresql-10

We now have the latest version of the PostgreSQL installed on our system. In our next tutorial, we will learn some important commands that are used for PostgreSQL administration. As for this tutorial, please do leave your valuble feedbacks or queries using the comment box below.

If you think we have helped you or just want to support us, please consider these :-

Connect to us: Facebook | Twitter | Google Plus

Donate us some of your hard earned money:

Linux TechLab is thankful for your continued support.


Passionate about Linux & open source. Loves to learn, read & write about Linux as well as new technologies.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *