尝试从虚拟机连接到 postgres 数据库时出现以下错误:
psycopg2.OperationalError: FATAL: password authentication failed for user "user1"
FATAL: password authentication failed for user "user1"
我已经创建了用户
CREATE USER user1 WITH PASSWORD 'pass1';
并将以下内容添加到我的 pg_hba.conf 文件中
local replication all trust
host replication all 127.0.0.1/32 trust
host replication all ::1/128 trust
host all all 0.0.0.0/0 md5
local all postgres md5
但是当使用 pscopg2.connect()
并指定数据库名称、用户、密码、端口和主机时,我仍然遇到相同的错误
作为参考,当尝试在虚拟机上使用 psql 连接到服务器时,我收到以下错误:
psql --host=localhost --port=5432 --username=user1 --dbname=postgres
Password for user user1:
psql: FATAL: password authentication failed for user "user1"
FATAL: password authentication failed for user "user1"
如果需要更多信息,请告诉我!