In this guide we will explore the installation of PostgreSQL 13 on CentOS 8 | RHEL 8 Linux server. PostgreSQL is a powerful, open source object-relational database system that safely store and scale the most complicated data workloads. The PostgreSQL database system is designed to assure users reliability, data integrity, robust feature set and extensibility. There is a large community behind its development to ensure innovation and strong reputation.

Install PostgreSQL 13 on CentOS 8 | RHEL 8

As of this article update PostgreSQL 13 is available running production workloads. All the software packages are available in the YUM repository supported officially by PostgreSQL team the installation process is simplified.

Before you start the installation ensure you’re running the latest release of CentOS 8 | RHEL 8 Linux system. You can run the yum update command to pull the latest updates.

sudo yum -y update
sudo systemctl reboot

Once the system is rebooted begin installation of PostgreSQL 13 on CentOS 8 | RHEL 8 server.

Step 1: Add PostgreSQL Yum Repository

The YUM repository supports both CentOS and RHEL family of Linux distributions. Once it is added, it will provide automatic updates for all supported versions of PostgreSQL throughout the support lifetime of PostgreSQL.

Run the following commands to add the repository that provides PostgreSQL packages to your CentOS / RHEL 8 server.

sudo dnf install

Accept installation when prompted by pressing the y key in your keyboard.

ependencies resolved.
 Package                                     Architecture                      Version                              Repository                               Size
 pgdg-redhat-repo                            noarch                            42.0-14                              @commandline                             11 k

Transaction Summary
Install  1 Package

Total size: 11 k
Installed size: 11 k
Is this ok [y/N]: y

Step 2: Install PostgreSQL 13 on CentOS 8 | RHEL 8

We need to disable the PostgreSQL AppStream repository on CentOS 8 | RHEL 8 Linux which contains some other version of PostgreSQL.

sudo dnf -qy module disable postgresql

Confirm the list of enabled repositories.

$ sudo dnf repolist
repo id                                                       repo name
AppStream                                                     CentOS-8 - AppStream
BaseOS                                                        CentOS-8 - Base
extras                                                        CentOS-8 - Extras
pgdg-common                                                   PostgreSQL common RPMs for RHEL/CentOS 8 - x86_64
pgdg10                                                        PostgreSQL 10 for RHEL/CentOS 8 - x86_64
pgdg11                                                        PostgreSQL 11 for RHEL/CentOS 8 - x86_64
pgdg12                                                        PostgreSQL 12 for RHEL/CentOS 8 - x86_64
pgdg13                                                        PostgreSQL 13 for RHEL/CentOS 8 - x86_64
pgdg95                                                        PostgreSQL 9.5 for RHEL/CentOS 8 - x86_64
pgdg96                                                        PostgreSQL 9.6 for RHEL/CentOS 8 - x86_64

Check to see if PostgreSQL 13 packages are available on the repository.

$ sudo yum search postgresql13
Last metadata expiration check: 0:00:45 ago on Sat 31 Oct 2020 08:04:30 AM CET.
=============================================================== Name Exactly Matched: postgresql13 ===============================================================
postgresql13.x86_64 : PostgreSQL client programs and libraries
=================================================================== Name Matched: postgresql13 ===================================================================
postgresql13-docs.x86_64 : Extra documentation for PostgreSQL
postgresql13-libs.x86_64 : The shared libraries required for any PostgreSQL clients
postgresql13-test.x86_64 : The test suite distributed with PostgreSQL
postgresql13-devel.x86_64 : PostgreSQL development header files and libraries
postgresql13-pltcl.x86_64 : The Tcl procedural language for PostgreSQL
postgresql13-plperl.x86_64 : The Perl procedural language for PostgreSQL
postgresql13-server.x86_64 : The programs needed to create and run a PostgreSQL server
postgresql13-contrib.x86_64 : Contributed source and binaries distributed with PostgreSQL
postgresql13-llvmjit.x86_64 : Just-in-time compilation support for PostgreSQL

Now install PostgreSQL 13 packages on your CentOS 8 | RHEL 8 server – both server and client.

sudo dnf install postgresql13 postgresql13-server

Agree to install if you’re okay with it.

Dependencies resolved.
 Package                                       Architecture                     Version                                    Repository                        Size
 postgresql13                                  x86_64                           13.0-1PGDG.rhel8                           pgdg13                           1.4 M
 postgresql13-server                           x86_64                           13.0-1PGDG.rhel8                           pgdg13                           5.5 M
Installing dependencies:
 libicu                                        x86_64                           60.3-2.el8_1                               BaseOS                           8.8 M
 postgresql13-libs                             x86_64                           13.0-1PGDG.rhel8                           pgdg13                           411 k

Transaction Summary
Install  4 Packages

Total download size: 16 M
Installed size: 63 M
Is this ok [y/N]: y

GPG key repository is also required.

Total                                                                                                                              13 MB/s |  16 MB     00:01
warning: /var/cache/dnf/pgdg13-e81daebfc8b779ec/packages/postgresql13-13.0-1PGDG.rhel8.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
PostgreSQL 13 for RHEL/CentOS 8 - x86_64                                                                                          1.6 MB/s | 1.7 kB     00:00
Importing GPG key 0x442DF0F8:
 Userid     : "PostgreSQL RPM Building Project <[email protected]>"
 Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
Is this ok [y/N]: y

Step 3: Initialize and start database service

PostgreSQL database initialization is required before you can use the database server.

$ sudo /usr/pgsql-13/bin/postgresql-13-setup initdb
Initializing database ... OK

The database main configuration file is  /var/lib/pgsql/13/data/postgresql.conf

$ ls  /var/lib/pgsql/13/data/
base    pg_commit_ts  pg_ident.conf  pg_notify    pg_snapshots  pg_subtrans  PG_VERSION
global  pg_dynshmem   pg_logical     pg_replslot  pg_stat       pg_tblspc    pg_wal      postgresql.conf
log     pg_hba.conf   pg_multixact   pg_serial    pg_stat_tmp   pg_twophase  pg_xact

Start the PostgreSQL database server and set it to start at boot.

$ sudo systemctl enable --now postgresql-13
Created symlink /etc/systemd/system/ → /usr/lib/systemd/system/postgresql-13.service.

Check the service status to confirm it is running.

$ systemctl status postgresql-13
● postgresql-13.service - PostgreSQL 13 database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql-13.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2020-07-09 23:35:30 CEST; 37s ago
  Process: 1860 ExecStartPre=/usr/pgsql-13/bin/postgresql-13-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
 Main PID: 1865 (postmaster)
    Tasks: 8 (limit: 12210)
   Memory: 17.3M
   CGroup: /system.slice/postgresql-13.service
           ├─1865 /usr/pgsql-13/bin/postmaster -D /var/lib/pgsql/13/data/
           ├─1867 postgres: logger
           ├─1869 postgres: checkpointer
           ├─1870 postgres: background writer
           ├─1871 postgres: walwriter
           ├─1872 postgres: autovacuum launcher
           ├─1873 postgres: stats collector
           └─1874 postgres: logical replication launcher

Jul 09 23:35:30 systemd&#91;1]: Starting PostgreSQL 13 database server...
Jul 09 23:35:30 postmaster&#91;1865]: 2020-07-09 23:35:30.180 CEST &#91;1865] LOG:  redirecting log output to logging collector process
Jul 09 23:35:30 postmaster&#91;1865]: 2020-07-09 23:35:30.180 CEST &#91;1865] HINT:  Future log output will appear in directory "log".
Jul 09 23:35:30 systemd&#91;1]: Started PostgreSQL 13 database server.

Step 4: Set PostgreSQL admin user’s password

Update the PostgreSQL admin user password.

$ sudo su - postgres 
]$ psql -c "alter user postgres with password 'StrongDBPassword'"

Step 5: Enabling remote Database connections (Optional)

Edit the file /var/lib/pgsql/13/data/postgresql.conf and set Listen address to your server IP address or “*” for all interfaces.

$ sudo vi /var/lib/pgsql/13/data/postgresql.conf
# line 59
listen_addresses = ''

Also set PostgreSQL to accept remote connections

$ sudo vi /var/lib/pgsql/13/data/pg_hba.conf

# Accept from anywhere (not recommended)
host all all md5

# Accept from trusted subnet (Recommended setting)
host all all md5

Restart the database service after saving the changes.

sudo systemctl restart postgresql-13

Test connection using the psql command while providing username and optionally database name.

$ psql -U <dbuser> -h <serverip> -p 5432 <dbname>

Step 6: Install pgAdmin 4 Web interface

pgAdmin is the leading Open Source feature-rich PostgreSQL administration and development platform that runs on Linux, Unix, Mac OS X, and Windows. Here is the link for the installation of pgAdmin4 on CentOS.

How To Install pgAdmin 4 on CentOS 8 Linux

Best Video courses to Learn PostgreSQL Database:

Read the official documentation for more in-depth knowledge on PostgreSQL database administration.

Your support is our everlasting motivation,
that cup of coffee is what keeps us going!

As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.


Please enter your comment!
Please enter your name here