python - django.db.utils.OperationalError : FATAL: password authentication failed for user "postgres"

标签 python django postgresql

我的设置都是本地的所有@authmethodlocal@。

就好像我无法进入我的用户“postgres”或“ladonna”。

我正在运行 python3 manage.py runserver。

本地主机、5432 等是默认的。

File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/psycopg2/__init__.py", line 126, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: FATAL:  password authentication failed for user "postgres"

最佳答案

用户postgres默认没有数据库密码。因此,检查文件/etc/postgresql/10/main/pg_hba.conf: 并将其更改为

local   all         postgres                          peer

或者在 psql shell 中你可以为用户 postgres 设置密码

ALTER USER postgres PASSWORD 'yourPassword';

设置密码后,在用户postgres的django设置中添加密码。

关于python - django.db.utils.OperationalError : FATAL: password authentication failed for user "postgres",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59691019/

相关文章:

python - 根据python中的一个值生成类似 'normal-distribution'的数据

python - 控制 Django ModelForm 输出

python - python 社交身份验证中缺少 session 状态

python - 将列表传递给 render(request) 时 CSS 失败

javascript - 如何使用 node-postgres 将多行正确插入 PG?

postgresql - 是否可以在 PostgreSQL 中动态创建字典?

数据库 : Insert from multipler servers

python - HttpRequest实例在Django中动态添加属性?

python - cherrypy:关闭发送带有静态目录和文件的 cookie

python - Tensorflow/Keras 意思是图像减法