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).

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 repositories2- 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,

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