简体   繁体   English

Postgres docker 错误:致命:用户密码验证失败

[英]Postgres docker error: FATAL: password authentication failed for user

I created a Postgres container with docker我用 docker 创建了一个 Postgres 容器

sudo docker run -d \
    --name dev-postgres \
    -e POSTGRES_PASSWORD=test \
    -e POSTGRES_USER=test \
    -v ${HOME}/someplace/:/var/lib/postgresql/data \
    -p 666:5432 \
    postgres

I give the Postgres instance test as a username and password as specified in the doc .我将 Postgres 实例测试作为文档中指定的用户名和密码。

The Postgres port (5432) inside the container is linked to my 666 port on the host.容器内的 Postgres 端口 (5432) 链接到我在主机上的 666 端口。

Now I want to try this out using psql现在我想用 psql 试试这个

psql --host=localhost --port=666 --username=test

I'm prompted to enter the password for user test and after entering test, I get系统提示我输入用户 test 的密码,输入 test 后,我得到

psql: error: FATAL:  password authentication failed for user "test"

There are different problems that can cause this有不同的问题可能导致这种情况

  • The version of Postgres on the host and the container might not be the same主机和容器上的 Postgres 版本可能不一样

    If you have to change the docker version of Postgres used, make sure that the container with the new version is not crashing.如果您必须更改使用的 Postgres 的 docker 版本,请确保使用新版本的容器没有崩溃。 Trying to change the version of Postgres while using the same directory for data might cause problem as the directory was initialized with the wrong version.在使用同一目录存储数据时尝试更改 Postgres 的版本可能会导致问题,因为该目录使用错误的版本初始化。

    You can use docker logs [container name] to debug if it crashes如果崩溃,您可以使用docker logs [container name]进行调试

  • There might be a problem with the volumes used by docker (something with cached value preventing the creation of a new user when env variable change) if you changed the env parameters.如果您更改了 env 参数,则 docker 使用的卷可能存在问题(具有缓存值的东西会在 env 变量更改时阻止创建新用户)。

    docker stop $(docker ps -qa) && docker system prune -af --volumes
  • If you have problem with some libraries that use Postgres, you might need to install some package to allow libraries to work with Postgres.如果您对某些使用 Postgres 的库有疑问,您可能需要安装一些 package 以允许库与 Postgres 一起使用。 Those two are the one Stack Overflow answers often reference.这两个是 Stack Overflow 经常参考的答案。
    sudo apt install libpq-dev postgresql-client
  • Other problems seem to relate to problems with docker configuration.其他问题似乎与 docker 配置的问题有关。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Docker Django Postgres 致命:用户“postgres”的密码验证失败 - Docker Django Postgres FATAL: password authentication failed for user "postgres Django Postgres docker-compose 连接错误主要失败:FATAL: password authentication failed for user foobar ERROR: 2 - Django Postgres docker-compose connection error mainly failed: FATAL: password authentication failed for user foobar ERROR: 2 docker-compose:致命:用户“postgres”的密码身份验证失败 - docker-compose: FATAL: password authentication failed for user "postgres" Postgres&Rails –严重:用户密码验证失败 - Postgres & Rails – FATAL: password authentication failed for user PostgreSQL:致命:用户“postgres”的密码身份验证失败 - PostgreSQL: FATAL: password authentication failed for user "postgres" psql:严重:用户“ postgres”的密码身份验证失败 - psql: FATAL: password authentication failed for user “postgres” 致命:用户 postgres aurora 的密码验证失败 - FATAL: password authentication failed for user postgres aurora 致命:用户“postgres”macos 的密码验证失败 - Fatal: password authentication failed for user "postgres" macos GCP 日志导出器报告错误:db=postgres,user=postgres 致命:用户“postgres”的密码验证失败 - GCP Logs Exporter is reporting error: db=postgres,user=postgres FATAL: password authentication failed for user "postgres" postgres / docker:用户的密码身份验证失败 - postgres / docker: password authentication failed for user
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM