将PostgreSQL密码加密从MD5更改为SHA [英] Change PostgreSQL password encryption from MD5 to SHA
问题描述
是否可以将PostgreSQL密码加密方法从MD5更改为SHA?
Is there a way to change the PostgreSQL password encryption method from MD5 to SHA?
如果可以,请告诉我如何?
If Yes, can you please tell me how?
我正在使用PostgreSQL 9.5
I am using PostgreSQL 9.5
推荐答案
Pg 10
在PostgreSQL 10中,您可以将 password_encryption
设置为 scram-sha-256
。来自文档
在
创建角色
或ALTER中指定密码时ROLE
而不写入ENCRYPTED
或UNENCRYPTED
,此参数确定密码是否为加密。默认值为md5,它将密码存储为MD5哈希。将此设置为纯文本将以明文形式存储。也接受on和off作为md5和plain的别名。 将此参数设置为scram-sha-256将使用SCRAM-SHA-256加密密码。
When a password is specified in
CREATE ROLE
orALTER ROLE
without writing eitherENCRYPTED
orUNENCRYPTED
, 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.
如果不实际修改源代码,则无法完成此操作。
This can not be done without actually modifying the source.
这篇关于将PostgreSQL密码加密从MD5更改为SHA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!