pgsql远程设置

postgresql默认情况下,远程访问不能成功,如果需要允许远程访问,需要修改两个配置文件,说明如下:
 
1.postgresql.conf
修改 #listen_addresses = 'localhost' 为:
listen_addresses = '*'
 
2.pg_hba.conf
在该配置文件的host all all 127.0.0.1/32 md5行下添加以下配置,或者直接将这一行修改为以下配置
# IPv4 local connections:
#host all all 127.0.0.1/32 trust
host all all 0.0.0.0/0 md
 
如果不希望允许所有IP远程访问,则可以将上述配置项中的0.0.0.0设定为特定的IP值。
 
说明:上面两个文件修改后如果要生效要重启数据库。
 
修改前,5432端口状态:
 
 
修改后,5432端口状态:
 
原文地址:https://www.cnblogs.com/liang545621/p/12605769.html