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,查看进程:
5,防火墙打开端口,以CentOS7为例
sudo firewall-cmd --permanent --zone=public --add-port=5432/tcp
sudo firewall-cmd --reload