Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 263
Mariusz Avatar asked Oct 02 '22 06:10

Mariusz


1 Answers

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.

like image 197
Bruno Avatar answered Oct 13 '22 12:10

Bruno