Linux 修改PostgreSQL外部访问白名单

1. 查找配置文件

# find / -name pg_hba.conf
# find / -name postgresql.conf

2.修改

  2.1 修改pg_hba.conf

 查找IPv4 local connections

   修改默认的

host all all 127.0.0.1/32 trust

 为

host all all 192.168.1.1/32 trust #IP全匹配
或
host all all 192.168.1.1/24 trust #IP匹配前三段
或
host all all 0.0.0.0/0 trust #全部允许

  2.2 修改postgresql.conf

 查找 Connection Settings

 修改默认的

listen_addresses = 'localhost'

 为

listen_addresses = '*'

重启postgresql服务

1. 查找配置文件

# find / -name pg_hba.conf
# find / -name postgresql.conf

2.修改

  2.1 修改pg_hba.conf

 查找IPv4 local connections

   修改默认的

host all all 127.0.0.1/32 trust

 为

host all all 192.168.1.1/32 trust #IP全匹配
或
host all all 192.168.1.1/24 trust #IP匹配前三段
或
host all all 0.0.0.0/0 trust #全部允许

  2.2 修改postgresql.conf

 查找 Connection Settings

 修改默认的

listen_addresses = 'localhost'

 为

listen_addresses = '*'

重启postgresql服务