小编Zep*_*rus的帖子

PostgreSQL 连接 URI 失败,但参数有效

使用 ssl 运行 postgreSQL 13.2。

我需要从需要连接 URI 的第三方应用程序连接到数据库,但它不起作用。因此,我使用具有相同凭据的两种不同格式测试了与 psql 的连接。一个有效,一个没有。

以下命令将我以 myuser 用户身份登录到 mydb:

# psql -U myuser -d mydb -h 127.0.0.1 -p 5432 -W
Password:
psql (13.2 (Debian 13.2-1.pgdg100+1))
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
Type "help" for help.

mydb=>
Run Code Online (Sandbox Code Playgroud)

但是这个命令失败了:

# psql postgresql://myuser:MYPASSWORD@127.0.0.1:5432/mydb?sslmode=require
psql: error: FATAL: password authentication failed for user "myuser"
Run Code Online (Sandbox Code Playgroud)

我正在使用完全相同的凭据。我已经验证了 10 多次。删除“sslmode=require”并不能解决问题。

我的 pg_hba.conf 文件包含:

host   mydb   myuser   127.0.0.1/32   password
Run Code Online (Sandbox Code Playgroud)

我把它放在我的 pg_hba.conf 文件的第一行,所以它不会挂在任何其他行上。

我究竟做错了什么?

postgresql

6
推荐指数
1
解决办法
348
查看次数

标签 统计

postgresql ×1