How to install and configure Postgresql on RHEL\Centos

Go to and choose your distribution (in my case RHEL family) and choose version of your OS and version of Postgresql

# yum install
# yum install postgresql11
# yum install postgresql11-server
# /usr/pgsql-11/bin/postgresql-11-setup initdb

Set PostgreSQL Server to Listen Addresses and Set Port

$nano /var/lib/pgsql/11/data/postgresql.conf 

listen_addresses = ‘*’
port = 5432

Set PostgreSQL Permissions

$nano /var/lib/pgsql/11/data/pg_hba.conf

Local networks
host all all xx.xx.xx.xx/xx md5
IPv4 local connections:
host all all md5

Enable to auto start after restart and run postgres, check the status of postgres

sudo systemctl enable postgresql-11
sudo systemctl start postgresql-11
sudo systemctl status postgresql-11

Set password „pass“ for user postgress

$sudo -u postgres psql
$ALTER USER postgres PASSWORD 'pass';

Checking for remote connection and give list of databases (My_IP = your addres)

$psql -h My_IP –p 5432 -U postgres

Check if firewall is disabled

$iptables -L

Should be something like this

Leave a Reply

Close Menu