Mariusz
Mariusz

Reputation: 177

OperationalError: FATAL: password authentication failed for user "UserName"

After you download the project from GitHub, trying to run it locally. I created a database using the command (I'm using Postgres 9.1):

postgres = # CREATE NameUser django createDB WITH PASSWORD 'MyPass';
CREATE ROLE
postgres = # CREATE DATABASE DatabaseName OWNER NameUser;
CREATE DATABASE

Then in the settings file I have this code:

DATABASES = {
     'default': {
         'ENGINE': 'django.db.backends.postgresql_psycopg2'
         'NAME': 'DatabaseName',
         'USER': 'NameUser'
         'PASSWORD': 'MyPass'
         'HOST': 'localhost',
         'PORT':'',
     }
}

after the command:./manage.py resetdb, receives:

OperationalError: FATAL: password authentication failed for user "NameUser"
FATAL: password authentication failed for user "NameUser"

I found on stackoverflow that the reason may be the file pg_hba.conf accordingly. After the change looks like this:

# Database administrative login by Unix domain socket
local   all             postgres                                md5
# "local" is for Unix domain socket connections only
local   all             all                                     md5
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5

Please for help.

Upvotes: 5

Views: 7896

Answers (1)

Bruno
Bruno

Reputation: 641

try:

CREATE "NameUser" django createDB WITH PASSWORD 'MyPass';

Note the double quotes around "NameUser". That's because of the SQL standard identifier case folding in PostgreSQL.

Upvotes: 4

Related Questions