-
找到配置文件目录
sudo find / -name pg_hba.conf
-
修改或添加配置信息
vim pg_hba.conf
host all all 192.168.1.1/32 md5 --/32代表只允许192.168.1.1访问 host all all 192.168.1.0/24 md5 --/24代表192.168.1.1~192.168.1.255都允许访问 host all all 192.168.0.0/16 md5 --/16代表192.168.1.1~192.168.255.255都允许访问 host all all 192.0.0.0/8 md5 --/8代表192.1.1.1~192.255.255.255都允许访问 host all all 0.0.0.0/0 md5 --/0代表所有ip地址都允许访问
-
找到 postgresql.conf 配置文件文件
vim postgresql.conf
在配置文件中添加一行 listen_addresses = '*'
-
重启数据库
service postgresql restart
-
测试连接
psql -h xxx.xxx.xxx.xxx -U postgres
postgres 数据库远程连接设置
最新推荐文章于 2024-06-27 09:00:00 发布