Postgresql: FATAL: password authentication for user "douglas"
I am trying to migrate DB from sqlite to postgresql ... so I typed:
sudo -u postgres psql
postgres=# ALTER USER postgres WITH PASSWORD 'newpassword';
and the output returns ALTER ROLE
but when i type python manage.py migrate
i always get the same error:
django.db.utils.OperationalError: FATAL: Password authentication failed for user "Douglas"
These are the database sections of my 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',
}
}
Note. When I run "ALTER USER postgres WITH PASSWORD" I enter the same password that is specified in settings.py.
source to share
The SQL you are using does not match the user you are trying to use.
You need to create a user if it doesn't exist:
CREATE USER douglas WITH PASSWORD 'vamointer';
or, if it exists, change this user password .
ALTER USER douglas WITH PASSWORD 'vamointer';
Once you do this, you are more fortunate. You may also need to assign permissions to this user .
source to share
Special characters in postgresql are converted to different characters at runtime. Make sure there are no special characters (#, $, etc.) in your password.
If you do, change the postgresql password as follows:
sudo -u postgresql psql
postgresql=#ALTER USER yourusername WITH PASSWORD
'set_new_password_without_special_character';
Make sure you don't forget ;
at the end of the postgresql command. Then run python manage.py
it and it should work!
source to share