Install Postgres on Cent OS.
Update System Packages:
sudo yum updateInstall PostgreSQL:
sudo yum install postgresql-server
Initialize the Database:
sudo postgresql-setup initdbStart and Enable PostgreSQL Service:
sudo systemctl start postgresql
sudo systemctl enable postgresql
Then finally setup according to the below description to enable publish access.
sudo nano /var/lib/pgsql/data/pg_hba.confMake sure the following line is uncommented or added:
host all all 0.0.0.0/0 md5sudo nano /var/lib/pgsql/data/postgresql.confFind the line that starts with listen_addresses and change its value to '*':
listen_addresses = '*'Restart PostgreSQL:
sudo systemctl restart postgresqlConfigure Firewall:
If you have a firewall enabled, you need to allow incoming connections on the PostgreSQL port (default is 5432):
sudo firewall-cmd --zone=public --add-port=5432/tcp --permanent
sudo firewall-cmd --reload
Switch to the postgres user:
sudo su - postgres
Switch to the postgres System User
Peer authentication works if the system user matches the PostgreSQL role. Switch to the postgres system user and then connect:
sudo -i -u postgres
psql
ALTER USER postgres WITH PASSWORD 'postgres_password';
Exit the PostgreSQL prompt:
\qSwitch back to your regular user account:
exitNow you are ready to login