PostgreSQL 将密码加密从 SCRAM 降级为 md5

Dan*_*974 8 postgresql md5 password-encryption psql postgresql-13

我需要将用户postgres的密码加密从scram-sha-265降级为md5

我尝试修改pg_hba.confpostgresql.conf文件,将密码加密从scram-sha-256更改为md5,但之后我无法连接到数据库。

我正在使用 PostgreSQL 13 和 PgAdmin 4 v5。

感谢您的任何帮助和建议!

PS:我必须这样做,因为 RStudio 无法通过 scram 身份验证管理连接。

Dan*_*974 7

我按照以下步骤解决了:

md5将文件postgresql.conf中的password_encryption 更改为

更改文件pg_hba.conf中出现的前 3 个scram-sha-256totrust

# "local" is for Unix domain socket connections only
local   all             all                                     trust
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 trust
Run Code Online (Sandbox Code Playgroud)

重启postgresql服务

执行psql -U postgres(不会要求您输入密码)

通过命令修改密码\password username

更改文件pg_hba.conf中出现的前 3 个trusttomd5

# "local" is for Unix domain socket connections only
local   all             all                                     md5
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
Run Code Online (Sandbox Code Playgroud)

重启postgresql服务