the*_*rit 16 git django postgresql operationalerror
我克隆了一个来自github的回购并正在研究它.该项目在django并使用postgres作为数据库.该项目现在处于生产阶段,我需要对其进行一些更改.数据库规格是:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
# Or path to database file if using sqlite3.
'NAME': 'project_name',
'USER': 'admin',
'PASSWORD': '',
# Empty for localhost through domain sockets or '127.0.0.1'
# for localhost through TCP.
'HOST': 'localhost',
'PORT': '5432',
}
}
Run Code Online (Sandbox Code Playgroud)
我想在我的本地主机上运行它,但我无法.我收到错误:
django.db.utils.OperationalError: fe_sendauth: no password supplied
Run Code Online (Sandbox Code Playgroud)
我已经搜索过这个问题,但找不到可以帮助我的解决方案.谁能告诉我问题出在哪里?
小智 17
如果要使用本地密码减去连接,则需要删除值"HOST","PORT"和"PASSWORD".
使用此配置,连接器将尝试使用unix域套接字进行连接,这是Postgres中默认允许的唯一允许密码连接
对于这个问题,我可以想到两种可能的解决方案。
首先,如果数据库没有密码,请删除PASSWORD密钥。例如:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'project_name',
'USER': 'admin',
'HOST': 'localhost',
'PORT': '5432',
}
}
Run Code Online (Sandbox Code Playgroud)
其次,如果数据库有密码,请在PASSWORD密钥中提供:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'project_name',
'USER': 'admin',
'PASSWORD': '<YOUR PASSWORD HERE...>',
'HOST': 'localhost',
'PORT': '5432',
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15975 次 |
| 最近记录: |