微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

远程连接postgresql需要的设置

今天在虚拟机上装了个Postgresql,用来做数据库服务器。可是从本机去连接Postgresql,确连接不上,报错:

SEVERE: Servlet.service() for servlet [default] in context with path [/Shop] threw exception [org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is org.apache.commons.dbcp.sqlnestedException: Cannot create PoolableConnectionFactory (FATAL: pg_hba.conf z X g"192.168.0.1" A [ U"postgres" A f [ ^ x [ X"shop2,SSL p G g )] with root cause
org.postgresql.util.PsqlException: FATAL: pg_hba.conf z X g"192.168.0.1" A [ U"postgres" A f [ ^ x [ X"shop2,SSL p G g
at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:398)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:173)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:64)
at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:136)

通过查资料得知:Postgresql 认只监听回环地址127.0.0.1。要想Postgresql监听其他的IP,要进行如下设置:

1、修改postgresql.conf文件

listen_address='localhost' ⇒  listen_address='*'
2、修改gp_hba.conf文件 在其中增加客户端的ip追加 # IPv4 local connections: host all all 192.168.198.200/32 password 192.168.198.200是需要访问的客户端的Ip 3、重启Postgresql

原文地址:https://www.jb51.cc/postgresql/195745.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐