設置遠程訪問,容許B類192.168.0.0/16 網段訪問,設置listen_addresses = '*'。數據庫服務器爲192.168.126.128。sql
#修改配置文件 [root@promote ~]# vim /var/lib/pgsql/11/data/pg_hba.conf #查看修改完成配置文件 [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 #打開IP訪問限制 [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) #修改完成配置 [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)
修改完成重啓數據庫服務。數據庫
[root@promote ~]# systemctl restart postgresql-11
修改數據庫訪問密碼,本文設置密碼是123456。vim
[root@promote ~]# su - postgres 上一次登陸:五 4月 12 19:10:14 CST 2019pts/1 上 -bash-4.2$ psql psql (11.2) 輸入 "help" 來獲取幫助信息. postgres=# ALTER ROLE postgres WITH PASSWORD '123456'; ALTER ROLE postgres=# exit
使用遠程數據庫鏈接客戶端鏈接。本文客戶端爲Dbeaver 6.0.2。bash
命令測試鏈接。服務器
[root@promote ~]# curl 192.168.126.128:5432 curl: (52) Empty reply from server [root@promote ~]#
使用qgis鏈接postgis。curl
安裝pgadmin4。配置鏈接信息後正常鏈接。ide