You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring应用经pgBouncer连接PostgreSQL时trust认证失败求助

问题定位与解决方案

核心原因

pgBouncer的trust认证逻辑和PostgreSQL原生的trust不同——pgBouncer需要本地维护一份允许连接的用户列表,哪怕后端数据库用trust允许任意用户,pgBouncer也会先校验用户是否在本地列表中,日志里的no such user: postgres就是直接触发认证失败的原因。

解决步骤

  • 配置pgBouncer用户列表

    1. 在pgbouncer.ini中指定用户列表文件路径:
      auth_file = /etc/pgbouncer/userlist.txt
      
      路径可根据你的实际部署调整。
    2. 在userlist.txt中添加postgres用户(trust模式下密码留空即可):
      "postgres" ""
      
  • 确认pgBouncer认证类型
    确保pgbouncer.ini中的认证类型设置为trust:

    auth_type = trust
    
  • 验证数据库映射配置
    在pgbouncer.ini的[databases]区块里,确保目标数据库Test69正确映射到后端PostgreSQL实例:

    Test69 = host=127.0.0.1 port=5432 dbname=Test69
    
  • 重启pgBouncer生效配置
    修改完配置后重启pgBouncer服务:

    sudo systemctl restart pgbouncer
    

内容的提问来源于stack exchange,提问作者sotiris6v

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.16 21:12:06