postgresql: FATAL: password authentication failed for user “douglas”
up vote
5
down vote
favorite
in first: sorry for this duplicate, but the others similar questions related for this issue always tell the same method to fix this problem, but did don't works for me.I trying to migrate a DB from sqlite to postgresql...so I type:
sudo -u postgres psql
postgres=# ALTER USER postgres WITH PASSWORD 'newpassword';
and the output return: "ALTER ROLE"
but when I type "python manage.py migrate" I receive always the same error:
django.db.utils.OperationalError: FATAL: password authentication
failed for user "douglas"
settings.py:
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'app',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'site_.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ,
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'site_.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
"""
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'),
}
"""
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'douglas_db',
'USER': 'douglas',
'PASSWORD': 'vamointer',
'HOST': '127.0.0.1',
'PORT': '5432',
}
}
# Password validation
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
#DATABASES = {'default': dj_database_url.config(default='postgres://127.0.0.1:5432/postgres_db_name')}
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.10/topics/i18n/
LANGUAGE_CODE = 'pt-br'
TIME_ZONE = 'America/Sao_Paulo'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.10/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
ps: When I run the 'ALTER USER postgres WITH PASSWORD' I put the same password defined in the settings.py.
Thanks!
python django postgresql
|
show 1 more comment
up vote
5
down vote
favorite
in first: sorry for this duplicate, but the others similar questions related for this issue always tell the same method to fix this problem, but did don't works for me.I trying to migrate a DB from sqlite to postgresql...so I type:
sudo -u postgres psql
postgres=# ALTER USER postgres WITH PASSWORD 'newpassword';
and the output return: "ALTER ROLE"
but when I type "python manage.py migrate" I receive always the same error:
django.db.utils.OperationalError: FATAL: password authentication
failed for user "douglas"
settings.py:
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'app',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'site_.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ,
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'site_.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
"""
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'),
}
"""
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'douglas_db',
'USER': 'douglas',
'PASSWORD': 'vamointer',
'HOST': '127.0.0.1',
'PORT': '5432',
}
}
# Password validation
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
#DATABASES = {'default': dj_database_url.config(default='postgres://127.0.0.1:5432/postgres_db_name')}
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.10/topics/i18n/
LANGUAGE_CODE = 'pt-br'
TIME_ZONE = 'America/Sao_Paulo'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.10/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
ps: When I run the 'ALTER USER postgres WITH PASSWORD' I put the same password defined in the settings.py.
Thanks!
python django postgresql
The error mentions the user accountuser
but your alter statement is changing the password of the userpostgres
. Lastly, your settings.py references yet another user;douglas
. Which user do you actually want to use, and are you running commands that reference just this user?
– Shadow
Mar 28 '17 at 4:58
2
Fair enough. What about the SQL query? You should be runningALTER USER douglas WITH PASSWORD 'vamointer';
– Shadow
Mar 28 '17 at 5:28
Sorry, I don't understand what you mean by that. Did you run the the query I wrote on the postgres database before attempting to run migrations?
– Shadow
Mar 28 '17 at 5:32
Now this error: "ERROR: role "douglas" does not exist" =[
– Douglas da Silva
Mar 28 '17 at 5:33
1
That's more like it :D I'll add an answer below.
– Shadow
Mar 28 '17 at 5:34
|
show 1 more comment
up vote
5
down vote
favorite
up vote
5
down vote
favorite
in first: sorry for this duplicate, but the others similar questions related for this issue always tell the same method to fix this problem, but did don't works for me.I trying to migrate a DB from sqlite to postgresql...so I type:
sudo -u postgres psql
postgres=# ALTER USER postgres WITH PASSWORD 'newpassword';
and the output return: "ALTER ROLE"
but when I type "python manage.py migrate" I receive always the same error:
django.db.utils.OperationalError: FATAL: password authentication
failed for user "douglas"
settings.py:
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'app',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'site_.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ,
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'site_.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
"""
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'),
}
"""
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'douglas_db',
'USER': 'douglas',
'PASSWORD': 'vamointer',
'HOST': '127.0.0.1',
'PORT': '5432',
}
}
# Password validation
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
#DATABASES = {'default': dj_database_url.config(default='postgres://127.0.0.1:5432/postgres_db_name')}
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.10/topics/i18n/
LANGUAGE_CODE = 'pt-br'
TIME_ZONE = 'America/Sao_Paulo'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.10/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
ps: When I run the 'ALTER USER postgres WITH PASSWORD' I put the same password defined in the settings.py.
Thanks!
python django postgresql
in first: sorry for this duplicate, but the others similar questions related for this issue always tell the same method to fix this problem, but did don't works for me.I trying to migrate a DB from sqlite to postgresql...so I type:
sudo -u postgres psql
postgres=# ALTER USER postgres WITH PASSWORD 'newpassword';
and the output return: "ALTER ROLE"
but when I type "python manage.py migrate" I receive always the same error:
django.db.utils.OperationalError: FATAL: password authentication
failed for user "douglas"
settings.py:
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'app',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'site_.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ,
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'site_.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
"""
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'),
}
"""
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'douglas_db',
'USER': 'douglas',
'PASSWORD': 'vamointer',
'HOST': '127.0.0.1',
'PORT': '5432',
}
}
# Password validation
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
#DATABASES = {'default': dj_database_url.config(default='postgres://127.0.0.1:5432/postgres_db_name')}
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.10/topics/i18n/
LANGUAGE_CODE = 'pt-br'
TIME_ZONE = 'America/Sao_Paulo'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.10/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
ps: When I run the 'ALTER USER postgres WITH PASSWORD' I put the same password defined in the settings.py.
Thanks!
python django postgresql
python django postgresql
edited Mar 28 '17 at 5:28
asked Mar 28 '17 at 4:53
Douglas da Silva
1501210
1501210
The error mentions the user accountuser
but your alter statement is changing the password of the userpostgres
. Lastly, your settings.py references yet another user;douglas
. Which user do you actually want to use, and are you running commands that reference just this user?
– Shadow
Mar 28 '17 at 4:58
2
Fair enough. What about the SQL query? You should be runningALTER USER douglas WITH PASSWORD 'vamointer';
– Shadow
Mar 28 '17 at 5:28
Sorry, I don't understand what you mean by that. Did you run the the query I wrote on the postgres database before attempting to run migrations?
– Shadow
Mar 28 '17 at 5:32
Now this error: "ERROR: role "douglas" does not exist" =[
– Douglas da Silva
Mar 28 '17 at 5:33
1
That's more like it :D I'll add an answer below.
– Shadow
Mar 28 '17 at 5:34
|
show 1 more comment
The error mentions the user accountuser
but your alter statement is changing the password of the userpostgres
. Lastly, your settings.py references yet another user;douglas
. Which user do you actually want to use, and are you running commands that reference just this user?
– Shadow
Mar 28 '17 at 4:58
2
Fair enough. What about the SQL query? You should be runningALTER USER douglas WITH PASSWORD 'vamointer';
– Shadow
Mar 28 '17 at 5:28
Sorry, I don't understand what you mean by that. Did you run the the query I wrote on the postgres database before attempting to run migrations?
– Shadow
Mar 28 '17 at 5:32
Now this error: "ERROR: role "douglas" does not exist" =[
– Douglas da Silva
Mar 28 '17 at 5:33
1
That's more like it :D I'll add an answer below.
– Shadow
Mar 28 '17 at 5:34
The error mentions the user account
user
but your alter statement is changing the password of the user postgres
. Lastly, your settings.py references yet another user; douglas
. Which user do you actually want to use, and are you running commands that reference just this user?– Shadow
Mar 28 '17 at 4:58
The error mentions the user account
user
but your alter statement is changing the password of the user postgres
. Lastly, your settings.py references yet another user; douglas
. Which user do you actually want to use, and are you running commands that reference just this user?– Shadow
Mar 28 '17 at 4:58
2
2
Fair enough. What about the SQL query? You should be running
ALTER USER douglas WITH PASSWORD 'vamointer';
– Shadow
Mar 28 '17 at 5:28
Fair enough. What about the SQL query? You should be running
ALTER USER douglas WITH PASSWORD 'vamointer';
– Shadow
Mar 28 '17 at 5:28
Sorry, I don't understand what you mean by that. Did you run the the query I wrote on the postgres database before attempting to run migrations?
– Shadow
Mar 28 '17 at 5:32
Sorry, I don't understand what you mean by that. Did you run the the query I wrote on the postgres database before attempting to run migrations?
– Shadow
Mar 28 '17 at 5:32
Now this error: "ERROR: role "douglas" does not exist" =[
– Douglas da Silva
Mar 28 '17 at 5:33
Now this error: "ERROR: role "douglas" does not exist" =[
– Douglas da Silva
Mar 28 '17 at 5:33
1
1
That's more like it :D I'll add an answer below.
– Shadow
Mar 28 '17 at 5:34
That's more like it :D I'll add an answer below.
– Shadow
Mar 28 '17 at 5:34
|
show 1 more comment
2 Answers
2
active
oldest
votes
up vote
5
down vote
accepted
The SQL you are running does not match the user you are attempting to use.
You will need to create the user if it does not exist
CREATE USER douglas WITH PASSWORD 'vamointer';
or if it does exist, change that users password instead.
ALTER USER douglas WITH PASSWORD 'vamointer';
Once you have done that you should have more luck. You may need to assign permissions to that user as well.
add a comment |
up vote
0
down vote
Special characters in postgresql are converted to different characters while execution. Make sure you do not have special characters (#,$,etc..) in your password.
If you do, change the postgresql password as follows:
sudo -u postgresql psql
postgresql=#alter yourusername with password
'set_new_password_without_special_character';
Make sure you do not forget the ;
at the end of postgresql command.
Then run python manage.py
and it should work!
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
accepted
The SQL you are running does not match the user you are attempting to use.
You will need to create the user if it does not exist
CREATE USER douglas WITH PASSWORD 'vamointer';
or if it does exist, change that users password instead.
ALTER USER douglas WITH PASSWORD 'vamointer';
Once you have done that you should have more luck. You may need to assign permissions to that user as well.
add a comment |
up vote
5
down vote
accepted
The SQL you are running does not match the user you are attempting to use.
You will need to create the user if it does not exist
CREATE USER douglas WITH PASSWORD 'vamointer';
or if it does exist, change that users password instead.
ALTER USER douglas WITH PASSWORD 'vamointer';
Once you have done that you should have more luck. You may need to assign permissions to that user as well.
add a comment |
up vote
5
down vote
accepted
up vote
5
down vote
accepted
The SQL you are running does not match the user you are attempting to use.
You will need to create the user if it does not exist
CREATE USER douglas WITH PASSWORD 'vamointer';
or if it does exist, change that users password instead.
ALTER USER douglas WITH PASSWORD 'vamointer';
Once you have done that you should have more luck. You may need to assign permissions to that user as well.
The SQL you are running does not match the user you are attempting to use.
You will need to create the user if it does not exist
CREATE USER douglas WITH PASSWORD 'vamointer';
or if it does exist, change that users password instead.
ALTER USER douglas WITH PASSWORD 'vamointer';
Once you have done that you should have more luck. You may need to assign permissions to that user as well.
answered Mar 28 '17 at 5:36
Shadow
4,42222237
4,42222237
add a comment |
add a comment |
up vote
0
down vote
Special characters in postgresql are converted to different characters while execution. Make sure you do not have special characters (#,$,etc..) in your password.
If you do, change the postgresql password as follows:
sudo -u postgresql psql
postgresql=#alter yourusername with password
'set_new_password_without_special_character';
Make sure you do not forget the ;
at the end of postgresql command.
Then run python manage.py
and it should work!
add a comment |
up vote
0
down vote
Special characters in postgresql are converted to different characters while execution. Make sure you do not have special characters (#,$,etc..) in your password.
If you do, change the postgresql password as follows:
sudo -u postgresql psql
postgresql=#alter yourusername with password
'set_new_password_without_special_character';
Make sure you do not forget the ;
at the end of postgresql command.
Then run python manage.py
and it should work!
add a comment |
up vote
0
down vote
up vote
0
down vote
Special characters in postgresql are converted to different characters while execution. Make sure you do not have special characters (#,$,etc..) in your password.
If you do, change the postgresql password as follows:
sudo -u postgresql psql
postgresql=#alter yourusername with password
'set_new_password_without_special_character';
Make sure you do not forget the ;
at the end of postgresql command.
Then run python manage.py
and it should work!
Special characters in postgresql are converted to different characters while execution. Make sure you do not have special characters (#,$,etc..) in your password.
If you do, change the postgresql password as follows:
sudo -u postgresql psql
postgresql=#alter yourusername with password
'set_new_password_without_special_character';
Make sure you do not forget the ;
at the end of postgresql command.
Then run python manage.py
and it should work!
edited 2 days ago
public static void main
7081321
7081321
answered 2 days ago
HAL 9000
313
313
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f43060857%2fpostgresql-fatal-password-authentication-failed-for-user-douglas%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
The error mentions the user account
user
but your alter statement is changing the password of the userpostgres
. Lastly, your settings.py references yet another user;douglas
. Which user do you actually want to use, and are you running commands that reference just this user?– Shadow
Mar 28 '17 at 4:58
2
Fair enough. What about the SQL query? You should be running
ALTER USER douglas WITH PASSWORD 'vamointer';
– Shadow
Mar 28 '17 at 5:28
Sorry, I don't understand what you mean by that. Did you run the the query I wrote on the postgres database before attempting to run migrations?
– Shadow
Mar 28 '17 at 5:32
Now this error: "ERROR: role "douglas" does not exist" =[
– Douglas da Silva
Mar 28 '17 at 5:33
1
That's more like it :D I'll add an answer below.
– Shadow
Mar 28 '17 at 5:34