目前仅支持认证明文密码和认证md5密码。收到 10

Fer*_*uel 1 c# postgresql npgsql postgresql-13

我在 postgresql13 中使用 npgsql,但是在尝试连接时出现以下错误:

目前仅支持认证明文密码和认证md5密码。收到 10

我的连接行是: NpgsqlConnection conn = new NpgsqlConnection("服务器= xxxx;端口= xxxx;用户ID = xxxx;密码= xxx;数据库=数据库;")

在 postgresql 9.6 中一切正常,但它迁移到版本 13 并产生了这个问题

Ser*_*ats 7

我在安装 Npgsql 4.5 和 postgresql-15 时遇到了同样的错误。在 postgresql.conf 文件中已经对password_encryption 行进行了注释。

对我来说解决问题的方法是修改 pg_hba.conf 并将文件中所有条目的方法从“scram-sha-256”更改为“密码”,例如

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     password
# IPv4 local connections:
host    all             all             127.0.0.1/32            password
# IPv6 local connections:
host    all             all             ::1/128                 password
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     password
host    replication     all             127.0.0.1/32            password
host    replication     all             ::1/128                 password
Run Code Online (Sandbox Code Playgroud)