[英]Postgresql - password authentication failed for user
Well, I've been working on a project on Django, but a friend of mine was facing a problem so he sent me his project (The entire folder).好吧,我一直在做一个关于 Django 的项目,但是我的一个朋友遇到了一个问题,所以他把他的项目(整个文件夹)发给了我。 Anyway, I tried to run the server but it didn't work.无论如何,我试图运行服务器,但它没有工作。 I tried to change the password and the username from the settings file, and when I tried to access the user, the username was changed (as the sql shell recognized it, I think ¯_(ツ)_/¯), but whenever I try to login with the password I wrote in the settings file it produces the following error:我试图从设置文件中更改密码和用户名,当我尝试访问用户时,用户名被更改(因为 sql shell 认出了它,我想¯_(ツ)_/¯),但每当我尝试使用我在设置文件中写入的密码登录它会产生以下错误:
django.db.utils.OperationalError: FATAL: password authentication failed for user "Youssef"
Here's the DATABASE
part in the settings.py file:这是 settings.py 文件中的DATABASE
部分:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'Boards_django',
'USER': 'Youssef',
'PASSWORD': '000000',
'HOST': 'localhost',
'PORT': '5432',
}
}
BTW, the database is recognized by the PgAdmin4:顺便说一句,数据库被 PgAdmin4 识别:
Any idea what should I do???知道我该怎么办吗???
Side note: I can't access the user, hence I'm not able to use any of the commands of postgresql Also, when I try to run the server or make anything on the database from VS Code, It raises the following error:旁注:我无法访问用户,因此我无法使用 postgresql 的任何命令另外,当我尝试从 VS Code 运行服务器或在数据库上进行任何操作时,它会引发以下错误:
django.db.utils.OperationalError: FATAL: password authentication failed for user "Youssef"
Here's the data in the pg_hba.conf
这是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
There are several possibilities:有几种可能性:
you used the wrong password你使用了错误的密码
there is no SCRAM-SHA-256 password set for the user没有为用户设置 SCRAM-SHA-256 密码
This could be either because no password is set, or because the password_encryption
parameter is set to md5
, or because the password has not been changed after password_encryption
was changed.这可能是因为没有设置密码,或者因为password_encryption
参数设置为md5
,或者因为在 password_encryption 更改后password_encryption
尚未更改。
To see the current setting:查看当前设置:
SHOW password_encryption;
To see the password:要查看密码:
SELECT rolpassword FROM pg_authid WHERE rolname = 'Youssef';
well, the problem was that my friend had a slight spelling difference in his database, when I added it to my databases in the PgAdmin page, It worked perfectly.好吧,问题是我的朋友在他的数据库中有轻微的拼写差异,当我在 PgAdmin 页面中将它添加到我的数据库时,它工作得很好。
Thanks to anyone who tried to help感谢任何试图提供帮助的人
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.