python - 如何使用 django postgres 和 docker-compose 调试密码身份验证失败
问题描述
你如何解决下面的问题
不知道我是如何搞砸我的postgresql配置(角色 + 密码等...)
我正在使用docker-compose django postgres13.3
db | 2021-07-23 13:05:23.221 UTC [1] LOG: starting PostgreSQL 13.3 (Debian 13.3-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
db | 2021-07-23 13:05:23.222 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
db | 2021-07-23 13:05:23.222 UTC [1] LOG: listening on IPv6 address "::", port 5432
db | 2021-07-23 13:05:23.226 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db | 2021-07-23 13:05:23.233 UTC [27] LOG: database system was shut down at 2021-07-23 12:59:50 UTC
db | 2021-07-23 13:05:23.252 UTC [1] LOG: database system is ready to accept connections
db | 2021-07-23 13:05:27.817 UTC [34] FATAL: password authentication failed for user "postgres"
db | 2021-07-23 13:05:27.817 UTC [34] DETAIL: Password does not match for user "postgres".
db | Connection matched pg_hba.conf line 99: "host all all all md5"
db | 2021-07-23 13:05:34.672 UTC [35] FATAL: password authentication failed for user "postgres"
db | 2021-07-23 13:05:34.672 UTC [35] DETAIL: Password does not match for user "postgres".
db | Connection matched pg_hba.conf line 99: "host all all all md5"
...
backend | Traceback (most recent call last):
backend | File "/usr/local/lib/python3.8/site-packages/django/db/backends/base/base.py", line 219, in ensure_connection
backend | self.connect()
backend | File "/usr/local/lib/python3.8/site-packages/django/utils/asyncio.py", line 26, in inner
backend | return func(*args, **kwargs)
backend | File "/usr/local/lib/python3.8/site-packages/django/db/backends/base/base.py", line 200, in connect
backend | self.connection = self.get_new_connection(conn_params)
backend | File "/usr/local/lib/python3.8/site-packages/django/utils/asyncio.py", line 26, in inner
backend | return func(*args, **kwargs)
backend | File "/usr/local/lib/python3.8/site-packages/django/db/backends/postgresql/base.py", line 187, in get_new_connection
backend | connection = Database.connect(**conn_params)
backend | File "/usr/local/lib/python3.8/site-packages/psycopg2/__init__.py", line 122, in connect
backend | conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
backend | psycopg2.OperationalError: FATAL: password authentication failed for user "postgres"
我试图手动编辑设置.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': "postgres",
'USER': "postgres",
'PASSWORD': "postgres",
'HOST': 'db',
'PORT': 5432,
}
}
通常的用户详细信息似乎没有任何作用postgres
,我访问了数据库psql postgres
,尝试更新密码,创建新角色,表和权限,但当我开始docker-compose up -d --build
并检查docker-compose logs
它仍然无法正常工作
这是我尝试首次亮相的第二天,请帮助
解决方案
任何遇到同样问题的人
你所要做的就是docker-compose down --volumes
然后
docker-compose up -d --build --force-recreate
:)
推荐阅读
- postgresql - Postgresql 导入转储,用户与 postgres 不同
- fastapi - 如何在 fast-api 中发送多个响应(FileResponse 和 JsonResponse)?
- flutter - 在颤振应用程序中添加提供程序包时出错
- visual-studio-code - 在 VS Code Ubuntu 中更改终端的复制和粘贴快捷方式
- javascript - Coldfusion 发送电子邮件
- windows - BATCH 中的 FINDSTR /E 匹配行尾的字符串的正确语法是什么?
- php - 当我以“多对一”关系运行“工匠:迁移”时出现问题
- python - 取消嵌套列表函数
- python-3.x - python3中的concurrent.futures.process.BrokenProcessPool
- javascript - 如何在对象数组中减去具有相似键的对象值?(不要与删除重复项混淆)