OperationalError:FATAL:用户的密码验证失败

时间:2017-01-12 13:58:44

标签: python django postgresql

昨天我试图在Digital Ocean上的Ubuntu 16.04服务器上设置django网站。我遇到了Potsgresql的一些问题,特别是当我认为我已经安装了所有文件并试图迁移文件时,最终我找到了这个帖子并按照所选择的答案对我来说非常有效

django.db.utils.OperationalError: could not connect to server: No such file or directory

在这样做后,我能够在我的网站上运行我的网站(但没有css):8000,我在那时称它为一天。

今天大约24小时后回到它并尝试做

python manage.py runserver

这样我就可以完成设置,我现在收到此错误

File "/home/david/.local/lib/python2.7/site-  packages/psycopg2/__init__.py", line 164, in connect
    conn = _connect(dsn, connection_factory=connection_factory,     async=async)
django.db.utils.OperationalError: FATAL:  password authentication     failed for user "django_user"
FATAL:  password authentication failed for user "django_user"

我尝试从其他线程重新创建步骤但是没有工作,我打开psql shell并重置密码并仔细检查我的密钥文件中的密码是否正确,我还检查了用户& #39; django_user'仍在那里,正确的数据库具有权限等。

这是我的Django settings.py文件

from .base import *
DEBUG = False
ADMINS = (
       ('My name', 'name@gmail.com'),
)
ALLOWED_HOSTS = ['domain name', 'www.domain name.co', 'ip address']

with open('/etc/django_keys/postgres_key.txt') as f:
        PSQL_KEY = f.read().strip()

DATABASES = {
        'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'django_db',
        'USER': 'django_user',
        'HOST': 'localhost',
        'PORT': '5432',
        'PASSWORD': PSQL_KEY,
        }
}

我对这一切感到非常困惑,24小时前情况好转,发生了什么变化?

感谢

编辑:我应该补充一点,我已经阅读了其他类似的问题,人们提出了有关编辑pg_hba.conf文件的解决方案,这是我以前从未做过的事情,我非常了解psql,我也想我知道为什么在我做其他改变之前,昨天工作正常。

当我以postgres用户身份登录psql然后查找所有用户和数据库时,我看到的是这样吗?

psql screengrab

0 个答案:

没有答案
相关问题