我在 Docker 中使用 Postgres 创建了一个容器,但是当我尝试连接数据库时,它告诉我密码错误,尽管我输入了正确的密码。
来自 IDE 的错误:[28P01] 致命:用户“testuser”的密码身份验证失败
我用来提升容器的命令: docker run -d --hostname test --name test -p 5401:5432 -e POSTGRES_USER=testuser -e POSTGRES_PASSWORD=password -e POSTGRES_DB=testdb -v /data:/var /lib/postgresql/data --restart=除非停止 postgres:14.5
容器控制台消息:
2024-03-11 02:34:48 2024-03-10 23:34:48.546 UTC [71] FATAL: password authentication failed for user "testuser"
2024-03-11 02:34:48 2024-03-10 23:34:48.546 UTC [71] DETAIL: Role "testuser" does not exist.
2024-03-11 02:34:48 Connection matched pg_hba.conf line 100: "host all all all scram-sha-256"
我使用的是 Windows 11。Docker 版本 4.22.0。也许这些信息会有用。
我尝试以某种方式从控制台与容器交互,但它一直说我的角色不存在,甚至“postgres”角色也不存在,即使 pgAdmin 有它。
它告诉我密码错误
提示密码验证失败因为您的用户不存在。
让我们看看删除了时间戳的情况。
FATAL: password authentication failed for user "testuser"
DETAIL: Role "testuser" does not exist.