gpt4 book ai didi

python - Django - (OperationalError) fatal error : Ident authentication failed for user "username"

转载 作者:太空狗 更新时间:2023-10-29 20:32:55 26 4
gpt4 key购买 nike

根据本手册,我编写了一个简单的 sqlalchemy-django 模型:http://lethain.com/replacing-django-s-orm-with-sqlalchemy/ ,这对我来说效果很好。
我的 Django 使用以下设置连接到远程 postgresql 数据库:

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'wetlab_dev', # Or path to database file if using sqlite3.
'USER': 'limlim', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': 'cab-27', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}

几天前它对我有用,但现在当我再次尝试加载“主页”时,它显示以下错误消息:

(OperationalError) FATAL:  Ident authentication failed for user "limlim"    

sqlalchemy 引擎配置是:

CONNECTION_STR = 'postgresql://limlim:@cab-27/wetlab_dev'

engine = sqlalchemy.create_engine(CONNECTION_STR)

似乎我没有更改任何与数据库配置相关的内容,但我仍然收到此错误消息。
另外,当我尝试使用我的用户名连接到远程服务器上的数据库时,我成功了,所以我想这不是我的用户名访问该数据库的权限问题。

如何克服这个错误?

最佳答案

您的 pg_hba.conf 配置为对来自本地主机 (127.0.0.1) 的连接使用“ident”身份验证。对于您的数据库和用户组合,您需要将其更改为 md5

关于python - Django - (OperationalError) fatal error : Ident authentication failed for user "username",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11339917/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com