我已经在与 PostgreSQL-9.6 数据库相同的 Linux 服务器上安装了 pgbouncer-1.7.2。当我尝试使用 pgbouncer 连接到本地数据库时,数据库要求输入密码。例如:
psql -p 6432 -U postgres -d mydb10 -h localhost
**Password for user postgres:**
输入密码后登录就OK了。相同的直接请求无需密码即可运行:
psql -p 5432 -U postgres -d mydb10 -h localhost
psql (9.6.5)
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type "help" for help.
mydb10=# \q
Pgbouncer 设置(不是全部):
[databases]
* = host=127.0.0.1 port=5432 auth_user=postgres pool_size=20
[pgbouncer]
listen_addr = *
listen_port = 6432
auth_type = md5
auth_file = /etc/pgbouncer/userlist.txt
;; auth_query = SELECT usename, passwd FROM pg_shadow WHERE usename=$1
PostgreSQL 设置(不是全部):
port = 5432
pg_hba.conf 中的所有 METHOD 都设置为“信任”。如果我设置auth_type = trust,通过 pgbouncer 的连接不需要密码。有趣的是,同样的配置,当 pgbouncer 安装在单独的服务器上时,没有这样的问题。
请让我知道您是否知道如何解决此问题。