Reputation: 1330
TL;DR manage migrate fails but manage dbshell works.
This is a dockerized dev environment on OSX10.6, boot2docker with django 1.8.4 and postgresql 9.4.4.
/manage.py migrate throws:
django.db.utils.OperationalError: FATAL: password authentication failed for user "xxxxx"
but here's the bit that confuses me, django dbshell works, copy and pasting the password out of the environment variable
root@df6501ab7341:/src/web# ./manage.py dbshell
Password for user xxxxx:
psql (9.4.4)
Type "help" for help.
xxxxx=# \du
List of roles
Role name | Attributes | Member of
--------------+------------------------------------------------+-----------
xxxxx | Superuser +| {}
| Password valid until infinity |
mpasysuser01 | | {}
postgres | Superuser, Create role, Create DB, Replication | {}
xxxxx=#
Django settings are:
# Database Configuration
DATABASES = {
'default': {
'ENGINE' : 'django.db.backends.postgresql_psycopg2',
'NAME' : os.environ.get('DATABASE_ENV_POSTGRES_USER' , ''), # the database name is the same as the dbo username
#ToDo Use unprivileged database user
# 'USER' : os.environ.get('DATABASE_ENV_UNPRIVILEGED_SQL_USER', ''),
'USER' : os.environ.get('DATABASE_ENV_POSTGRES_USER', ''),
'PASSWORD' : os.environ.get('DATABASE_ENV_POSTGRES_PASSWORD', ''),
'HOST' : os.environ.get('DATABASE_PORT_5432_TCP_ADDR' , ''),
'PORT' : os.environ.get('DATABASE_PORT_5432_TCP_PORT' , ''),
},
}
and the database logs show:
database_1 | FATAL: password authentication failed for user "xxxxx"
database_1 | DETAIL: Connection matched pg_hba.conf line 95: "host all all 0.0.0.0/0 md5"
Upvotes: 4
Views: 4711
Reputation: 125
I second what @larconda said.
I was racking my brain and decided to print by:
Open the shell
import os
print(your variable here)
That should provide some input - it turned out to be a missing space for me.
Upvotes: 3