How to install PostgreSQL database server on CentOS 8

PostgreSQL is an free-opensource object-relational database management system. The objective of this tutorial is to perform an installation and basic configuration of PostgreSQL server on RHEL 8 / CentOS 8 Linux server.

In this tutorial you will learn:

  • How to install PostgreSQL database server on RHEL 8 / CentOS 8
  • How to start and enable PostgreSQL database server
  • How to access PostgreSQL database from localhost and remote location
  • How to set password for the default postgres user
  • How to enable PostgreSQL to listen on all networks
  • How to secure PostgreSQL remote connection with MD5 password authentication
  • How to open PostgreSQL firewall port
  • How to establish remote connection to PostgreSQL server using psql client
Initializing and accessing PostgreSQL database on Red Hat Enterprise Linux 8

Initializing and accessing PostgreSQL database on Red Hat Enterprise Linux 8

Software Requirements and Conventions Used

CategoryRequirements, Conventions or Software Version Used
SystemRHEL 8 / CentOS 8
SoftwarePostgreSQL Server 10.5-1.el8
OtherPrivileged access to your Linux system as root or via the sudo command.
Conventions# – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

Local PostgreSQL Installation and database access step by step instructions



  1. Install PostreSQL server.
    Execute the below dnf command to perform a PostreSQL server package installation:
    # dnf install postgresql-server
  2. Initialize PostgreSQL database:
    # postgresql-setup –initdb –unit postgresql * Initializing database in ‚/var/lib/pgsql/data‘ * Initialized, logs are in /var/lib/pgsql/initdb_postgresql.log
  3. Start PostgreSQL and optionally enable it to start after reboot.
    # systemctl start postgresql
    # systemctl enable postgresql

    At this point the PostreSQL server should be up and running and listening on localhost port 5432. Use ss command to confirm that this is the case:$ ss -nlt State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 0.0.0.0:111 0.0.0.0:* LISTEN 0 32 192.168.122.1:53 0.0.0.0:* LISTEN 0 128 0.0.0.0:22 0.0.0.0:* LISTEN 0 128 127.0.0.1:5432 0.0.0.0:* LISTEN 0 128 [::]:111 [::]:* LISTEN 0 128 [::]:22 [::]:* LISTEN 0 128 [::1]:5432 [::]:*
Jan D.
Jan D.

"The only real security that a man will have in this world is a reserve of knowledge, experience, and ability."

Articles: 675

Leave a Reply

Vaše e-mailová adresa nebude zveřejněna. Vyžadované informace jsou označeny *