首页 > 解决方案 > Postgresql - 用户的密码认证失败

问题描述

好吧,我一直在做一个关于 Django 的项目,但是我的一个朋友遇到了一个问题,所以他把他的项目(整个文件夹)发给了我。无论如何,我试图运行服务器,但它没有工作。我试图从设置文件中更改密码和用户名,当我尝试访问用户时,用户名被更改(因为 sql shell 识别它,我认为¯_(ツ)_/¯),但每当我尝试使用我在设置文件中写入的密码登录它会产生以下错误:

django.db.utils.OperationalError: FATAL: password authentication failed for user "Youssef"

这是DATABASEsettings.py 文件中的部分:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'Boards_django',
        'USER': 'Youssef',
        'PASSWORD': '000000',
        'HOST': 'localhost',
        'PORT': '5432',
    }
}

顺便说一句,数据库被 PgAdmin4 识别:

在此处输入图像描述

知道我该怎么办吗???

旁注:我无法访问用户,因此我无法使用 postgresql 的任何命令另外,当我尝试从 VS Code 运行服务器或在数据库上进行任何操作时,它会引发以下错误:

django.db.utils.OperationalError: FATAL: password authentication failed for user "Youssef"

这是里面的数据pg_hba.conf

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     scram-sha-256
# IPv4 local connections:
host    all             all             127.0.0.1/32            scram-sha-256
# IPv6 local connections:
host    all             all             ::1/128                 scram-sha-256
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     scram-sha-256
host    replication     all             127.0.0.1/32            scram-sha-256
host    replication     all             ::1/128                 scram-sha-256

标签: pythondjangopostgresqlauthenticationpgadmin-4

解决方案


好吧,问题是我的朋友在他的数据库中有轻微的拼写差异,当我在 PgAdmin 页面中将它添加到我的数据库时,它工作得很好。

感谢任何试图提供帮助的人


推荐阅读