首页 > 解决方案 > 使用新的 docker-compose 时用户的密码验证失败

问题描述

我正在使用 django-cookiecutter 模板,并且第二次用于新项目。它无法连接到 postgres 并出现以下错误:

postgres_1  | 2018-04-30 14:54:09.747 UTC [1] LOG:  database system is ready to accept connections
postgres_1  | 2018-04-30 14:54:10.029 UTC [28] FATAL:  password authentication failed for user "IViLGLIEWLBDGBnsAuoOEhtFaKrqKxfX"
postgres_1  | 2018-04-30 14:54:10.029 UTC [28] DETAIL:  Role "IViLGLIEWLBDGBnsAuoOEhtFaKrqKxfX" does not exist.
postgres_1  |   Connection matched pg_hba.conf line 95: "host all all all md5"
django_1    | PostgreSQL is unavailable (sleeping)...

一位维护者解释了这一点:

the thing is, every time you bootstrap the project POSTGRES_USER and POSTGRES_PASSWORD get reset to a newly-generated random values

我试图删除所有 docker 容器,但没有成功,不知道我该如何解决这个问题?我没有旧凭据来替换它们。

标签: postgresqldocker

解决方案


https://github.com/webyneter的帮助下(django-cookiecutter 的贡献者)

解决方案如下:

  • 要查看现有卷:docker volume ls
  • 删除相应的卷docker volume rm <your project_slug>_postgres_backup_local <your project_slug>_postgres_data_local

推荐阅读