我在 makemigrations 时遇到此错误
setting.py中数据库的databe设置为:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'freecodeschool',
'USER': 'fcs_admin',
'PASSWORD': '',
'HOST': 'localhost',
'PORT': '',
}
}
当我运行迁移时出现此错误。
return func(*args, **kwargs)
File "/home/danish-khan/django_drf/django/lib/python3.8/site-packages/django/db/backends/postgresql/base.py", line 187, in get_new_connection
connection = Database.connect(**conn_params)
File "/home/danish-khan/django_drf/django/lib/python3.8/site-packages/psycopg2/__init__.py", line 127, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: fe_sendauth: no password supplied
当我提供密码时,它会给我这个错误。
connection = Database.connect(**conn_params)
File "/home/danish-khan/django_drf/django/lib/python3.8/site-packages/psycopg2/__init__.py", line 127, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: FATAL: password authentication failed for user "fcs_admin"
FATAL: password authentication
答案 0 :(得分:1)
您似乎还没有填写密码,而您的数据库想要为用户“fcs_admin”提供密码。除此之外,您也应该添加您的数据库端口。 (默认为 5432) 如果您不确定 postgres 用户的密码,您可以使用以下命令:
sudo su postgres
\du