PostgreSQL is a powerful, open-source object-relational database system that uses and extends the SQL language combined with many features that safely store and scale the most complicated data workloads. PostgreSQL has earned a strong reputation for its proven architecture, reliability, data integrity, robust feature set, extensibility, and the dedication of the open-source community behind the software to consistently deliver performant and innovative solutions.

PostgreSQL comes with many features aimed to help developers build applications, administrators to protect data integrity and build fault-tolerant environments, and help you manage your data no matter how big or small the dataset. In addition to being free and open-source, PostgreSQL is highly extensible. For example, you can define your own data types, build out custom functions, even write code from different programming languages without recompiling your database.

In this guide, we will explain how to install the latest version of PostgreSQL on a CentOS 7 server.

Deploying your cloud server
If you have not already registered with Cloudwafer, you should begin by getting signed up. Take a moment to create an account after which you can easily deploy your own cloud servers.

Once you have signed up, log into your Cloudwafer Client Area with the password provided in your mail and deploy your Cloudwafer cloud server.

Updating System Packages

It is always recommended that you update the system to the latest packages before beginning any major installations. This is done with the command below:

sudo yum update

Next, we need to add the Postgres yum repository by typing:

sudo rpm -Uvh

You can check here for more repository package rpm for various operating systems.

Step One – Install PostgreSQL 10 Server
Now that we have successfully enabled the PostgreSQL yum repository on our system, type the following command to install PostgreSQL 10 and the contrib package for additional utilities and functionality:

sudo yum install postgresql10-server postgresql10 postgresql-contrib

When prompted for confirmation, type y to proceed.

Step Two – Initialize PGDATA
After our installation, we need to create a new PostgreSQL database cluster by initializing the database with the command below:

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

Step Three – Start and Enable PostgreSQL Server
After our initialization, we need to start and enable the PostgreSQL service to start on boot using the following commands:

sudo systemctl start postgresql-10.service
sudo systemctl enable postgresql-10.service

You can check the status of the PostgreSQL service using the command below:

sudo systemctl status postgresql-10.service

Step Four - Configure PostgreSQL
By default, PostgreSQL does not allow password authentication. We can change this by editing PostgreSQL's host-based authentication (HBA) configuration.

Type the following command to edit the HBA configuration using nano.

sudo nano /var/lib/pgsql/data/pg_hba.conf

Locate the lines that look like the screenshot below

Replace ident with md5, as shown in the screenshot below:

Save and exit.

We have successfully configured PostgreSQL to allow password authentication.

Also, by default, PostgreSQL will create a Linux user named postgres to access the database software. In order to use Postgres, we'll need to log into that account. Type the command below to log into the account:

sudo -i -u postgres

You will be prompted to enter your current user password and then will be given a shell prompt for the postgres user.

You can get a Postgres prompt immediately by typing:


Exit out of the PostgreSQL prompt by typing:


You can read the official documentation on PostgreSQL here.