password authentication failed

Chris Angelico rosuav at gmail.com
Wed Jul 15 20:25:02 CEST 2015


On Thu, Jul 16, 2015 at 3:13 AM, Gary Roach <gary719_list1 at verizon.net> wrote:
> Every time I try to do a python manage.py migrate I get:
> django.db.utils.OperationalError: FATAL:  password
> authentication failed for user "postgres"
> FATAL:  password authentication failed for user "postgres"
>
>
>         DATABASES = {
>             'default': {
>                 'USER': 'postgres',
>                 'PASSWORD': 'xxxxxx', # A valid debian pw
>             }
>         }

PostgreSQL users are not the same as Unix users, and their passwords
aren't necessarily the same. I would recommend *not* using the
postgres user, which is the database superuser; instead, create a new
user explicitly. On most Debian PostgreSQL installations, you should
be able to invoke 'psql' while running as user 'postgres', either by
su'ing to postgres or with sudo, for instance:

$ sudo sudo -u postgres psql

That should get you into a database CLI as superuser. Your prompt
should look like this:

postgres=#

You should then be able to create a regular user, and grant
appropriate permissions:

postgres=# create user archives password 'traded-links-linguistics-informal';
CREATE ROLE
postgres=# grant all on database archivedb to archives;
GRANT

(Make sure you have the semicolons at the ends, otherwise you'll think
it's done nothing. It's actually waiting for you to type more lines
for the same command, but the prompt difference is so subtle that it's
easy to think it's silently ignoring you.)

Then you should be able to use user name 'archives' and password
'traded-links-linguistics-informal' (of course, you don't want to use
that; that's just what my password generating parrot came up with)
instead of 'postgres' and whatever the Unix password was.

Incidentally, I usually don't have any password on my postgres Unix
user, nor on the corresponding database users. Safer to use sudo, eg
to root and then down to postgres, as shown above.

ChrisA


More information about the Python-list mailing list