Here we are configuring PostgreSQL on an Oracle  VirtualBox RH 7 to demonstrate the process.

Default database directory is “/var/lib/pgsql/<ver>/data”


Initialise the PostgreSQL database

# /usr/pgsql-9.6/bin/postgresql96-setup initdb

Initializing database … OK


User password/peer Access

# cd /var/lib/pgsql/9.6/data

in  pg_hba.conf change METHOD column from “ident” or “peer” to “password” or MD5, I use password. To allow access from the host running the vbox we will allow all network access.

Change pg_hba.conf lines to:

# vi pg_hba.conf

  • # local all
  • local all all password
  • # IPv4 local connections:
  • host all all password
  • # IPv6 local connections:
  • host all all ::1/128 password

N.B. we coul use md5 etc instead of password

# systemctl restart postgresql-9.6


Network Access

Now set up PostgreSQL so it will allow connections from the network.

add/change the listen address to all addresses

# vi postgresql.conf

listen_addresses = ‘*’

# systemctl restart postgresql-9.6

# systemctl restart httpd


Password postgres user

root # su – postgres

postgres $ psql

=# \password

=# CREATE EXTENSION adminpack;

=# \quit

postgres $ exit