python - Postgresql - 用户的密码认证失败
问题描述
好吧,我一直在做一个关于 Django 的项目,但是我的一个朋友遇到了一个问题,所以他把他的项目(整个文件夹)发给了我。无论如何,我试图运行服务器,但它没有工作。我试图从设置文件中更改密码和用户名,当我尝试访问用户时,用户名被更改(因为 sql shell 识别它,我认为¯_(ツ)_/¯),但每当我尝试使用我在设置文件中写入的密码登录它会产生以下错误:
django.db.utils.OperationalError: FATAL: password authentication failed for user "Youssef"
这是DATABASE
settings.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
解决方案
好吧,问题是我的朋友在他的数据库中有轻微的拼写差异,当我在 PgAdmin 页面中将它添加到我的数据库时,它工作得很好。
感谢任何试图提供帮助的人
推荐阅读
- swift - Swift,无法将 Firebase 存储 URL 获取到数据库
- wordpress - 在 Elementor 中使用 Accordion 关闭内容很困难
- java - 如何使用 StanfordCoreNLP 添加用户字典
- android - Android Studio:生成签名 apk 以更新现有应用程序时出现“未安装应用程序”错误
- android - 数据库存储API和DOM存储API有什么区别
- php - 如何使用 DOMDocument PHP 从网站获取类值
- ms-access - Ms Access ListBox,由vba代码设置时值未更新为所选项目
- model - 导出带有纹理和材质的虚幻引擎模型
- linux - 命令行中施加的时间限制似乎并没有限制运行时间
- npm - 必须安装一个用于 webpack 的 CLI - 无法让 webpack 运行