如何在 Debian 的 Postgres 10 中使用 scram-sha-256?获取 "FATAL: password authentication failed"

How to use scram-sha-256 in Postgres 10 in Debian? Getting "FATAL: password authentication failed"

我编辑了 pg_hba.conf:

sudo su postgres
nano /etc/postgresql/10/main/pg_hba.conf

并添加了这一行:

local   all             username                               scram-sha-256

并将该文件中的所有 md5 更改为 scram-sha-256

作为 postgres 用户,我创建了一个具有超级用户权限的新用户:

sudo su postgres
psql

CREATE USER username WITH SUPERUSER PASSWORD 'password';

然后我重新启动了 Postgres:

/etc/init.d/postgresql restart

并尝试使用 pgAdmin4 登录,我在其中更改了数据库连接属性下的用户名。但这和 psql -U username testdb < ./testdb.sql 都不能像我得到的那样工作:

FATAL: password authentication failed for user "username"

那么如何让 Postgres 在我的 Debian9/KDE 机器上使用 scram-sha-256?当我将 pg_hba.conf 中的所有 md5 保持原样时,它会更早地工作。

The fine manual 说:

To upgrade an existing installation from md5 to scram-sha-256, after having ensured that all client libraries in use are new enough to support SCRAM, set password_encryption = 'scram-sha-256' in postgresql.conf, make all users set new passwords, and change the authentication method specifications in pg_hba.conf to scram-sha-256.