postgresql设置远程访问

postgresql默认情况下,远程访问不能成功,如果需要允许远程访问,需要修改两个配置文件,说明如下:

cd /etc/postgresql-9.4   (这个目录可能不同)

1.postgresql.conf

将该文件中的listen_addresses项值设定为“*”

2.pg_hba.conf

在该配置文件的host all all 127.0.0.1/32 md5行下添加以下配置,或者直接将这一行修改为以下配置

host    all    all    0.0.0.0/0    md5

也可以设置能内网可以访问

host    all    all   192.168.99.0/24    trust

如果不希望允许所有IP远程访问,则可以将上述配置项中的0.0.0.0设定为特定的IP值。

猜你喜欢

转载自wzgdavid.iteye.com/blog/2316817