远程连接postgresql需要的设置

前端之家收集整理的这篇文章主要介绍了远程连接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.f2er.com/postgresql/195745.html

猜你在找的Postgre SQL相关文章