将 PostgreSQL 密码加密从 MD5 更改为 SHA

Change PostgreSQL password encryption from MD5 to SHA

有没有办法将 PostgreSQL 密码加密方法从 MD5 更改为 SHA?

如果是,你能告诉我怎么做吗?

我正在使用 PostgreSQL 9.5

第 10 页

使用 PostgreSQL 10,您可以将 password_encryption 设置为 scram-sha-256。来自 the docs

When a password is specified in CREATE ROLE or ALTER ROLE without writing either ENCRYPTED or UNENCRYPTED, this parameter determines whether the password is to be encrypted. The default value is md5, which stores the password as an MD5 hash. Setting this to plain stores it in plaintext. on and off are also accepted, as aliases for md5 and plain, respectively. Setting this parameter to scram-sha-256 will encrypt the password with SCRAM-SHA-256.

Pg 9.x

如果不实际修改源代码,这是无法完成的。