Postgresql10允许远程访问配置 安装PostgreSQL10数据库之后,默认只能本地访问连接。如果想在其他主机上访问PostgreSQL10数据库服务器,就需要对pg_hba.conf和postgresql.conf这两个文件进行配置。所在目录如下:
/var/lib/pgsql/10/data/
1.修改pg_hba.conf文件
在data/pg_hba.conf中
# TYPE DATABASE USER ADDRESS METHOD
# IPv4 local connections:
host all all 127.0.0.1/32 md5
host all all 0.0.0.0/0 md5
2.修改postgresql.conf文件
在安装目录下data/postgresql.confi文件中将
#listen_addresses='localhost’
修改为
listen_addresses = '*'
修改完成后重启数据库
[root@localhost data]# systemctl restart postgresql-10
附:查看监听的端口
[root@localhost data]# netstat -antpl
ActiveInternet connections (servers and established)
ProtoRecv-Q Send-Q LocalAddressForeignAddressState PID/Program name
tcp 00127.0.0.1:6310.0.0.0:* LISTEN 1286/cupsd
tcp 000.0.0.0:54320.0.0.0:* LISTEN 3985/postmaster
tcp 00127.0.0.1:250.0.0.0:* LISTEN 1495/master
tcp 00127.0.0.1:60100.0.0.0:* LISTEN 3079/sshd: root@pts
tcp 000.0.0.0:80690.0.0.0:* LISTEN 4031/python3
tcp 000.0.0.0:1110.0.0.0:* LISTEN 1/systemd
tcp 00192.168.122.1:530.0.0.0:* LISTEN 1775/dnsmasq
tcp 000.0.0.0:220.0.0.0:* LISTEN 1290/sshd
tcp 0010.128.25.135:543210.128.30.218:61157 ESTABLISHED 4041/postgres: post
tcp 0010.128.25.135:543210.128.30.218:61160 ESTABLISHED 4042/postgres: post
tcp 0010.128.25.135:543210.128.30.218:61161 ESTABLISHED 4043/postgres: post
tcp 05210.128.25.135:2210.128.30.218:60051 ESTABLISHED 3079/sshd: root@pts
tcp6 00::1:631:::* LISTEN 1286/cupsd
tcp6 00:::5432:::* LISTEN 3985/postmaster
tcp6 00::1:25:::* LISTEN 1495/master
tcp6 00::1:6010:::* LISTEN 3079/sshd: root@pts
tcp6 00:::111:::* LISTEN 1/systemd
tcp6 00:::21:::* LISTEN 1311/vsftpd
tcp6 00:::22:::*
学习|生活|分享|积累|永不停步
请留下你指尖的温度
让太阳拥抱你
微信ID:haopython
![c9f0f1cd406b3f51b6227033cb24bae7.png](https://i-blog.csdnimg.cn/blog_migrate/a7471d4da74fececf1f3bb3d8df00810.jpeg)