解决postgresql客户端不能访问的方法

小编给大家分享一下解决postgresql客户端不能访问的方法,希望大家阅读完这篇文章后大所收获,下面让我们一起去探讨吧!

做程序调用postgresql数据库的时候,后台出现这么一条错误: 

java.sql.SQLException: No pg_hba.conf entry for host 210.230.203.160, user postgres, database rinri01 

这条错误是什么意思?为什么会出现呢? 

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

解决方法:

修改pg_hba.conf,增加需要访问的客户端IP,具体示例如下:

路径:D:\Program Files\PostgreSQL\9.2\data

# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
host    all             all             200.200.203.0/24        md5
host    all             all             200.200.202.0/24        md5
host    all             all             172.16.101.0/24         md5
host    all             all             172.16.201.0/24         md5
host    all             all             172.16.14.0/24         md5
host    all             all             172.16.206.0/24         md5

看完了这篇文章,相信你对解决postgresql客户端不能访问的方法有了一定的了解,想了解更多相关知识,欢迎关注行业资讯频道,感谢各位的阅读!