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
Software Requirements and Conventions Used
Category | Requirements, Conventions or Software Version Used |
---|---|
System | RHEL 8 / CentOS 8 |
Software | PostgreSQL Server 10.5-1.el8 |
Other | Privileged 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
- Install PostreSQL server.
Execute the belowdnf
command to perform a PostreSQL server package installation:
# dnf install postgresql-server - 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 - 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 port5432
. Usess
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 [::]:*