PostgreSQL连接报错‘no pg_hba.conf entry‘及FATAL: could not load pg_hba.conf

当程序链接PostgreSQL 时,可能会报错:No pg_hba.conf entry。

这条错误的原因是因为客户端远程访问postgresql受限所致,因为postgresql默认情况下除本机外的机器是不能连接的。

【解决方法】

修改PostgreSQL安装目录下 /data/postgresql.conf 文件

IPv4 local connections:下添加

host    all             all             162.165.1.103/32	    trust

在这里插入图片描述

32是子网掩码的网段;md5是密码验证方法,可以改为trust

允许本地使用PGAdmin4登录数据库,数据库地址localhost,用户user1,数据库user1db:

host    user1db    user1    127.0.0.1/32    md5

postgresql.conf里的监听地址设置为: listen_addresses = '*'

在这里插入图片描述




当程序链接PostgreSQL 时出现 FATAL: could not load pg_hba.conf

【错误原因】

网址、网段部分不正确

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_42547014/article/details/112603009