pgAdmin无法远程访问postgresql

版权声明:转载请注明出处 https://blog.csdn.net/geol200709/article/details/89211782

打开pgAdmin,然后添加局域网内另外一台机子的pg数据库,但报错:

could not connect to server: connection timed out (0x0000274c/10060) is the server running on host 10.10.6.7 and accepting tcp/ip connections on port 5432?

搜索一番,网上的解决方案是:
修改 C:\Program Files\PostgreSQL\10\data (安装目录因人而异) 下面两个文件(红色框)
+ postgresql.conf
其中 postgresql.conf 修改:

listen_addresses = '*'
port = 5432

其实我打开文件时就是长这样,无需修改

pg_hba.conf 修改:
在其最下面增加一行

host    all             all             0.0.0.0/0               md5

如果不想所有的ip访问,则将 0.0.0.0 换成允许访问的特定的ip

然后重启服务
service


然而,仍然不起效果!

最后增加一步,即通过防火墙放行数据库端口 5432

步骤:
控制面板 》Windows防火墙 》高级设置 》入站规则 》 新建规则 》
入站规则
要创建的规则类型,选择端口
入站规则选择tcp
剩下的,一路点击下一步即可。
这时就能自由访问了

猜你喜欢

转载自blog.csdn.net/geol200709/article/details/89211782