加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

远程连接postgresql需要的设置

发布时间:2020-12-13 17:29:19 所属栏目:百科 来源:网络整理
导读:今天在虚拟机上装了个PostgreSQL,用来做数据库服务器。可是从本机去连接PostgreSQL,确连接不上,报错: SEVERE: Servlet.service() for servlet [default] in context with path [/Shop] threw exception [org.springframework.transaction.CannotCreateTr

今天在虚拟机上装了个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。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读