postgresql数据库无法连接

kh0724 2018-07-23 04:38:25
因为需要供其他人进行数据库连接 所以按照网上对pg_hba.conf进行了配置
# TYPE DATABASE USER ADDRESS METHOD
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
host all all 192.168.0.0/24 md5
# IPv6 local connections:
host all all ::1/128 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
#host replication postgres 127.0.0.1/32 md5
#host replication postgres ::1/128 md5

进行设置后 仍无法连接数据库
url="jdbc:postgresql://192.168.0.1:5432/

...全文
2284 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
sxyweiren 2018-08-21
  • 打赏
  • 举报
回复
postgresql.conf
将该文件中的listen_addresses项值设定为“*”

另外,pg_hba.conf 我比较倾向于设定为
host all all 0.0.0.0/0 md5

注意对齐
huafei3311979 2018-08-14
  • 打赏
  • 举报
回复
reload了没?
zjcxc 2018-07-25
  • 打赏
  • 举报
回复
具体的失败信息是什么?
kh0724 2018-07-25
  • 打赏
  • 举报
回复
org.postgresql.util.PSQLException: 致命错误: 无法加载pg_hba.conf (pgjdbc: autodetected server-encoding to be EUC_CN, if the message is not readable, please check database logs and/or host, port, dbname, user, password, pg_hba.conf)
at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:443)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:217)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:51)
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:215)
at org.postgresql.Driver.makeConnection(Driver.java:404)
at org.postgresql.Driver.connect(Driver.java:272)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.lintstudio.libs.database.PostgreSQLOperator.<init>(PostgreSQLOperator.java:20)
at org.lintstudio.homeapp.dboperator.DatabaseUtils.<init>(DatabaseUtils.java:24)
at org.lintstudio.homeapp.dboperator.DatabaseUtils.getInstance(DatabaseUtils.java:29)
at org.lintstudio.homeapp.dboperator.DatabaseUtils.queryChildInfo(DatabaseUtils.java:47)
at org.lintstudio.homeapp.dboperator.test.main(test.java:11)
Exception in thread "main" java.lang.NullPointerException
at org.lintstudio.libs.database.PostgreSQLOperator.executeQuery(PostgreSQLOperator.java:47)
at org.lintstudio.homeapp.dboperator.DatabaseUtils.queryChildInfoInPrivate(DatabaseUtils.java:53)
at org.lintstudio.homeapp.dboperator.DatabaseUtils.queryChildInfo(DatabaseUtils.java:47)
at org.lintstudio.homeapp.dboperator.test.main(test.java:11)

我现在连本地的服务器都登不上了 因为修改了那个文本内容
本地服务器现在输入密码后始终连不上

我的目的是需要不在同一局域网内 可以让别人的电脑可以连接上我的数据库

zjcxc 2018-07-24
  • 打赏
  • 举报
回复
确认一下 listen_addresses 的配置
kh0724 2018-07-24
  • 打赏
  • 举报
回复
也按照网上进行修改了 但是就是没用 尝试连线失败

952

社区成员

发帖
与我相关
我的任务
社区描述
PostgreSQL相关内容讨论
sql数据库数据库架构 技术论坛(原bbs)
社区管理员
  • PostgreSQL社区
  • yang_z_1
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧