How to Install PostgreSQL 10 on CentOS/RHEL and Fedora

PostgreSQL is a powerful, highly scalable, open source and cross-platform object-relational database system that runs on Unix-like operating systems including Linux and Windows OS. It is an enterprise level database system which is highly reliable and offers data integrity and correctness to users.

In this article, we will explain how to install latest version of PostgreSQL 10 on CentOS, RHEL, Oracle Enterprise Linux, Scientific Linux and Fedora using official PostgreSQL Yum repository.

Add PostgreSQL Yum Repository

This official PostgreSQL Yum repository will combine with your Linux system and offers automatic updates for all supported versions of PostgreSQL on RedHat based distributions such as CentOS, Scientific Linux and Scientific Linux, as well as current versions of Fedora.

Note that due to the shorter Fedora support cycle, not all versions are available and we suggest that do not use Fedora for server deployments.

To use the yum repository, follow these steps:

--------------- On RHEL/CentOS 7 and Scientific Linux/Oracle Linux 7 --------------- 
# yum install

--------------- On 64-Bit RHEL/CentOS 6 and Scientific Linux/Oracle Linux 6 --------------- 
# yum install

--------------- On 32-Bit RHEL/CentOS 6 and Scientific Linux/Oracle Linux 6 --------------- 
# yum install

--------------- On Fedora 26 --------------- 
# dnf install

--------------- On Fedora 25 --------------- 
# dnf install

--------------- On Fedora 24 --------------- 
# dnf install
Enable PostgreSQL Yum Repository

Enable PostgreSQL Yum Repository

Install PostgreSQL Server

After adding PostgreSQL yum repository in your respective Linux distribution, use the following command to install PostgreSQL server and client packages.

# yum install postgresql10-server postgresql10   [On RedHat based Distributions]
# dnf install postgresql10-server postgresql10   [On Fedora Linux]
Install PostgreSQL Server

Install PostgreSQL Server

Important: PostgreSQL data directory /var/lib/pgsql/10/data/ contains all of the data files for the database.

Initialize PostgreSQL Database

Due to some policies for Red Hat based distributions, the PostgreSQL installation will not be active for automatic start or have the database initialized automatically. To complete your database installation, you need to initialize your database before using it for first time.

# /usr/pgsql-10/bin/postgresql-10-setup initdb
Initialize PostgreSQL Database

Initialize PostgreSQL Database

Start and Enable PostgreSQL Server

After database initialize completes, start PostgreSQL service and enable PostgreSQL service to auto start on system boot.

--------------- On SystemD --------------- 
# systemctl start postgresql-10
# systemctl enable postgresql-10
# systemctl status postgresql-10 

--------------- On SysVinit --------------- 
# service postgresql-10 start
# chkconfig postgresql-10 on
# service postgresql-10 status
Start PostgreSQL Server

Start PostgreSQL Server

Verify PostgreSQL Installation

After installing PostgreSQL 10 on your server, verify its installation by connecting to postgres database server.

# su - postgres
$ psql

psql (10.0)
Type "help" for help.

If you want you can create a password for user postgres for security purpose.

postgres=# \password postgres
Set PostgreSQL User Password

Set PostgreSQL User Password

You can find more information at the PostgreSQL Homepage:

Also check out these articles about popular database management systems:

  1. How to Install and Secure MariaDB 10 in CentOS 7
  2. How to Install and Secure MariaDB 10 in CentOS 6
  3. Install MongoDB Community Edition 3.2 on Linux Systems

That’s all! Hope you find this article useful. If you have any questions or thoughts to share, use the comment section below.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Aaron Kili

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide
The Complete Linux System Administrator Bundle
Become an Ethical Hacker Bonus Bundle

You may also like...

5 Responses

  1. Olivia says:

    Thank for sharing the nice tutorial. I followed it to install PostgreSQL.

  2. Anonemouse says:

    CentOS 6.9:

    Instead of this:

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

    You need to run this:

    # service postgresql-10 initdb

Got something to say? Join the discussion.

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.