首先:抱歉这个副本,但其他与此问题相关的类似问题总是告诉同样的方法来解决这个问题,但确实对我不起作用.我试图将数据库从sqlite迁移到postgresql ...所以我键入:
sudo -u postgres psql
postgres=# ALTER USER postgres WITH PASSWORD 'newpassword';
Run Code Online (Sandbox Code Playgroud)
并且输出返回:" ALTER ROLE "
但是当我键入" python manage.py migrate "时,我总是收到同样的错误:
django.db.utils.OperationalError:致命:用户"douglas"的密码验证失败
settings.py:
# Old, using mysqlite
"""
DATABASES = {
#'default': {
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
#}
'default': dj_database_url.config(default='postgres://localhost:5432/postgres_db_name'),
}
"""
# New, using postgres
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'douglas_db',
'USER': 'douglas',
'PASSWORD': 'vamointer',
'HOST': '127.0.0.1',
'PORT': '5432',
}
}
Run Code Online (Sandbox Code Playgroud)
ps:当我运行' ALTER USER postgres WITH PASSWORD '时,我将相同的密码设置在settings.py中.
谢谢!