版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/a964921988/article/details/80618661
PostgreSQL安装完成后是不能从本机之外的机器连接的
按以下步骤修改配置
1,安装目录/data/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地址都允许访问
加入一行允许内网IP访问
2,安装目录/data/postgresql.conf
listen_addresses = '*'
在这里加入星号允许访问
3,重启postgres服务
4,防火墙打开端口,以CentOS7为例
sudo firewall-cmd --permanent --zone=public --add-port=5432/tcp
sudo firewall-cmd --reload