Postgres and Django - Postgres User won't authenticate

First, I'm a linux noob. So if I've missed something basic, please let me know.

I'd like to check my steps for creating a user for postgres and then allowing that user to authenticate form django to postgres and do teh database work.

SU to postgres. $ su - postgres

As postgres, create a database. $ createdb dbname

As postgres, login to dbname. $ psql -d dbname -U postgres

Create the DB user: $ CREATE USER awesome PASSWORD 'something';

Using CREATE USER assigns login to that user.

That all works. But the only way to actually authenticate to the database is to su to that user.

Now, I add that user, database and password to my Django settings.py file. But when I try to syncdb, I get:

Ident authentication failed for user "awesome"

In my stack trace.

I'm confused what I'm missing. Any suggestions would be welcome. DO I have to set up authentication on my server with postgres?

Dave

1 Reply

it's been a long time since I used postreg (unfortunately), but I believe you have to do two things.

One, you created the database as the user postgres, owned by postres, rather than as your awesome user, so you'll need to use the grant sql command to give rights to the awesome user.

What i used to do was use the createuser command, then createdb command with a switch to say create the db as user (eg) awesome.

Two, you probably need to look at a file called pghba.something (pghba.conf?) hiding somewhere in /etc. try

find /etc/ -name pg_hba.*

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct