CentOS 7 Enables Remote Connection and Uses Client Connections such as Posgis

Keywords: Database PostgreSQL vim curl

Set remote access, allow class B 192.168.0.0/16 segment access, and set listen_addresses ='*'. The database server is 192.168.126.128.

#Modify configuration files
[root@promote ~]# vim /var/lib/pgsql/11/data/pg_hba.conf
#View Modification Completion Profile
[root@promote ~]# egrep -v "^#|^$" /var/lib/pgsql/11/data/pg_hba.conf 
local   all             all                                     peer
host    all             all             127.0.0.1/32            ident
host    all             all             192.168.0.0/16          md5
host    all             all             ::1/128                 ident
local   replication     all                                     peer
host    replication     all             127.0.0.1/32            ident
host    replication     all             ::1/128                 ident
[root@promote ~]# vim /var/lib/pgsql/11/data/postgresql.conf
#Open IP access restrictions
[root@promote ~]# vim /var/lib/pgsql/11/data/postgresql.conf
 59 #listen_addresses = 'localhost'         # what IP address(es) to listen on;
 60                                         # comma-separated list of addresses;
 61                                         # defaults to 'localhost'; use '*' for all
 62                                         # (change requires restart)
#Modify Complete Configuration
[root@promote ~]# vim /var/lib/pgsql/11/data/postgresql.conf
 59 listen_addresses = '*'                  # what IP address(es) to listen on;
 60                                         # comma-separated list of addresses;
 61                                         # defaults to 'localhost'; use '*' for all
 62                                         # (change requires restart)

The modification completes the restart of the database service.

[root@promote ~]# systemctl restart postgresql-11

Modify the database access password, the password set in this article is 123456.

[root@promote ~]# su - postgres
Last logon: May 1219:10:14 CST 2019pts/1
-bash-4.2$ psql
psql (11.2)
Enter "help" to get help information.

postgres=# ALTER ROLE postgres WITH PASSWORD '123456';
ALTER ROLE
postgres=# exit

Connect client connections using remote databases. The client of this article is Dbeaver 6.0.2.

Command test connection.

[root@promote ~]# curl 192.168.126.128:5432
curl: (52) Empty reply from server
[root@promote ~]# 

Use qgis to connect postgis.

Install pgadmin4. Connect normally after configuring connection information.

Posted by SergiuGothic on Fri, 12 Apr 2019 15:54:32 -0700