PostgreSQL一些简单问题以及解决办法

本文介绍了如何解决PostgreSQL中常见的连接问题,包括调整postgresql.conf文件中的listen_addresses设置以允许远程连接,修改pg_hba.conf文件来正确配置身份验证方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题:
org.postgresql.util.PSQLException: Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
解决办法:Edit /var/lib/pgsql/data/postgresql.conf file
Change
#listen_addresses = 'localhost'
to 
listen_addresses = '*'

问题:
org.postgresql.util.PSQLException: FATAL: no pg_hba.conf entry for host "<host_ip>", user "fkong", database "fkong", SSL off
解决办法:
Edit /var/lib/pgsql/data/pg_hba.conf file
Add below line under "# IPv4 local connections:"
"host    all         all         <host_ip>/32         password"
或者

"host    all         all         0.0.0.0/0                 trust"
问题:
org.postgresql.util.PSQLException: FATAL: Ident authentication failed for user "fkong"
解决办法:
Edit /var/lib/pgsql/data/pg_hba.conf file
Change 
"host    all         all         <host_ip>/32         ident"
to 
"host    all         all         <host_ip>/32         password"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值