Tuesday, February 15, 2022

How To Configure PostgreSQL To Allow Remote Connections On Rocky Linux 8

 in This Tutorial you will Learn " How To Configure PostgreSQL To Allow Remote Connections On Rocky Linux 8"
                          
By default, PostgreSQL Server allow access to clients localy using Unix sockets.
PostgreSQL is an advanced, enterprise-class, and open-source relational database system.
________________________________________________________________________________________
Server - Os:  Rocky Linux 8.5  64Bit      | IP -192.168.1.60        |Hostname - server.yourdomain.com
_________________________________________________________________________________________
cat /etc/system-release ; hostname ; hostname -I ; sestatus ; dnf groupinstall "Development Tools" -y
sudo dnf install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
dnf -qy module disable postgresql ; dnf -y install postgresql14 postgresql14-server
/usr/pgsql-14/bin/postgresql-14-setup initdb
systemctl start postgresql-14 ; systemctl enable postgresql-14 ; systemctl status postgresql-14

Set PostgreSQL Admin Password -
su - postgres
psql -c "alter user postgres with password 'password'"
exit

Configure PostgreSQL Server for Remote Access -
nano /var/lib/pgsql/14/data/postgresql.conf
listen_addresses = '*'
nano /var/lib/pgsql/14/data/pg_hba.conf
host all all 127.0.0.1/32 ident - host all all 0.0.0.0/0 md5
systemctl restart postgresql-14 ; systemctl status postgresql-14
firewall-cmd --add-service=postgresql --permanent ; firewall-cmd --reload
________________________________________________________________________________________
cat /etc/system-release ; hostname ; hostname -I ; sestatus ; dnf groupinstall "Development Tools" -y
192.168.1.60
dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
dnf -qy module disable postgresql ; dnf install -y postgresql14-server
/usr/pgsql-14/bin/postgresql-14-setup initdb
systemctl start postgresql-14 ; systemctl enable postgresql-14
firewall-cmd --add-service=postgresql --permanent ; firewall-cmd --reload
psql -U postgres -p 5432 -h 192.168.1.60            password
_________________________________________________________________________________________

No comments:

Post a Comment