繁体   English   中英

如何使用 django postgres 和 docker-compose 调试密码验证失败

[英]how to debug password authentication failed with django postgres and 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

:)

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM