postgresql - Postgres docker“用户“postgres”没有分配密码。”
问题描述
我正在使用 docker 运行 Postgres 图像。它曾经在 Windows10 和 Ubuntu 18.04 上运行没有任何问题。
在 Ubuntu 系统上重新克隆项目password authentication failed for user "postgres"
后,运行docker-compose up
.
在 Ubuntu 系统上重新克隆项目之前,它可以正常运行,并且在 Windows10 系统上仍然可以正常运行。
我的docker-compose.yml
:
version: '2'
services:
postgresql:
image: 'bitnami/postgresql:latest'
ports:
- '5432:5432'
environment:
- POSTGRESQL_USERNAME=someuser
- POSTGRESQL_PASSWORD=mysecretpassword
- POSTGRESQL_DATABASE=mydatabase
我试图sudo docker system prune
删除所有停止的容器及其未使用的网络。这并不能解决问题。
我需要更改/做什么才能使 Postgres 映像能够再次在 Ubuntu 系统上成功运行?
完整的错误:
postgresql_1 | nami INFO Initializing postgresql
postgresql_1 | postgre INFO ==> No injected postgresql.conf file found.
Creating default postgresql.conf file...
postgresql_1 | postgre INFO ==> No injected pg_hba.conf file found. Creating default pg_hba.conf file...
postgresql_1 | postgre INFO ==> Deploying PostgreSQL from scratch...
postgresql_1 | postgre INFO ==> Creating database mydatabase...
postgresql_1 | postgre INFO ==> Creating user "someuser"...
postgresql_1 | postgre INFO ==> Granting access to "someuser" to the database mydatabase...
postgresql_1 | postgre INFO ==> Configuring PostgreSQL...
postgresql_1 | postgre INFO ==> Configuring replication parameters...
postgresql_1 | postgre INFO ==> Configuring permissions for config files...
postgresql_1 | postgre INFO
postgresql_1 | postgre INFO
########################################################################
postgresql_1 | postgre INFO Installation parameters for postgresql:
postgresql_1 | postgre INFO User: someuser
postgresql_1 | postgre INFO Password: ***************
postgresql_1 | postgre INFO Database: mydatabase
postgresql_1 | postgre INFO (Passwords are not shown for security reasons)
postgresql_1 | postgre INFO
########################################################################
postgresql_1 | postgre INFO
postgresql_1 | nami INFO postgresql successfully initialized
postgresql_1 | INFO ==> Starting postgresql...
postgresql_1 | 2019-04-15 09:31:18.582 GMT [125] LOG: listening on IPv4 address "0.0.0.0", port 5432
postgresql_1 | 2019-04-15 09:31:18.583 GMT [125] LOG: listening on IPv6 address "::", port 5432
postgresql_1 | 2019-04-15 09:31:18.587 GMT [125] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
postgresql_1 | 2019-04-15 09:31:18.599 GMT [132] LOG: database system was shut down at 2019-04-15 09:31:18 GMT
postgresql_1 | 2019-04-15 09:31:18.603 GMT [125] LOG: database system is ready to accept connections
postgresql_1 | 2019-04-15 09:31:24.414 GMT [139] FATAL: password authentication failed for user "postgres"
postgresql_1 | 2019-04-15 09:31:24.414 GMT [139] DETAIL: User "postgres" has no password assigned.
postgresql_1 | Connection matched pg_hba.conf line 95: "host all all 0.0.0.0/0 md5"
postgresql_1 | 2019-04-15 09:31:27.492 GMT [140] FATAL: password authentication failed for user "postgres"
postgresql_1 | 2019-04-15 09:31:27.492 GMT [140] DETAIL: User "postgres" has no password assigned.
解决方案
如果您检查 docker 映像的文档(https://hub.docker.com/r/bitnami/postgresql),它会说当您设置POSTGRESQL_USERNAME
postgres 用户时不会分配密码并且您将无法使用它登录到数据库。
使用您指定的用户。
推荐阅读
- javascript - React Hook - 具有纯函数的 setData 以使用 prevData 但内部进行了深入比较
- javascript - 为什么当我关闭并重新打开反应组件(材料表)时会发生内存泄漏并渲染速度变慢?
- python - Scipy wavfile 在 AWS Lambda 上采样 [时间限制错误]。为什么?
- google-sheets - 当 B 列为空时计算 A 列中的值,反之亦然
- python - 一个 azure 托管的 ubuntu 代理将 conda 添加到路径,评估 conda shell,创建/激活 conda 环境 - 最后尝试 pip 安装但失败
- java - 如何最佳地找到满足给定条件的数组的子集数?
- python - 拒绝区号之后和本地号码(美国)之前的可选空格
- python - 在“with”语句中调用构造函数
- php - 使用最新的 Wordpress Docker 映像时出现超时问题
- netflix-zuul - 关于zuul路由和过滤的问题 是否可以在过滤中进行路由