Install Postgresql 9.5 in Centos 7

1.Update yum

yum update

2. Add Postgresql repository 

yum -y install http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-3.noarch.rpm

3. Installation 

yum -y groupinstall "PostgreSQL Database Server 9.5 PGDG"

Congratulation! now you have Postgresql 9.5 Database installed.

4.Configuration 

initial postgresql 
/usr/pgsql-9.5/bin/postgresql95-setup initdb
start postgresql service 

systemctl start postgresql-9.5.service

service to start on boot
systemctl enable postgresql-9.5.service

5.Allow all host to access 

vim /var/lib/pgsql/9.5/data/postgresql.conf

find this #listen_addresses = 'localhost' change to listen_addresses ='*'

6.Allow by IP or users 

vim /var/lib/pgsql/9.5/data/pg_hba.conf
host all all  0.0.0.0/0    md5 (to allow access from other server) it means allow from all IP and all user with password.
restart Postgresql service
systemctl restart postgresql-9.5.service

7.Firewall 

Allow all access from all ip and allow port 5432
firewall-cmd --permanent --zone=trusted --add-source=0.0.0.0/0
firewall-cmd --permanent --zone=trusted --add-port=5432/tcp
reload firewall to make effective 
firewall-cmd --reload

8.Set password for user postgres

switch to postgres user 
su postgres -
access to default database
psql
change password
\passowrd
    then type your password and confirm it, this password you can use to access to Postgesql databases

Thank you! 🦆




Comments