0

I've configured everything as i would in another distro (i'm an arch user, and i installed opensuse on a desktop machine).

As :

  • Django and all it requirements (psycopg)
  • Postgresql
  • Created a User for my django server
  • Created a Database
  • Granted all power for the database for my new user

Then, when starting syncdb to start working i get this message (I've changed users etc.. in this thread for user:question, password:password, database:question as it is in reality with other words):

FATAL:  Ident authentication failed for user "question"

After lurking i got the idea to change my pg_hba.conf file (located at : /var/lib/pgsql/data/pg_hba.conf)

This is what I have:

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     trust
# IPv4 local connections:
host    all             all             127.0.0.1/32            ident
# IPv6 local connections:
host    all             all             ::1/128                 ident

My django conf file contains :

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'question',
        'USER': 'question',
        'PASSWORD': 'password',
        'HOST': '127.0.0.1',
        'PORT': '',
    }
}

I don't understand what i missed here, any ideas ?

cp151
  • 189
  • 2
  • 17
  • Did you confirm that you connect with the same info via `psql`? – Michael Mior Oct 14 '12 at 13:55
  • Sorry, i havn't but no i can't connect via the same infos via psql (with this command : su; su postgres; psql -U question; i get : psql: FATAL: database "question" does not exist, this is returned after typing : create user question; as postgres and getting a successful message, however i can login if i create a database called question but i still won't be able to manage.py syncdb) – cp151 Oct 14 '12 at 14:01
  • Can you try manually inserting something in the database when connected via `psql`? It sounds like a permissions problem. – Michael Mior Oct 14 '12 at 14:03
  • question=> create table test(test VARCHAR(32)); CREATE TABLE question=> INSERT INTO test(test) values ('test'); INSERT 0 1 – cp151 Oct 14 '12 at 14:09

2 Answers2

1

Edit the /var/lib/pgsql/data/pg_hba.conf file and change the method from trust to md5. This way Postgres will ask for a password.

Also remember to reload the configuration file.

arturhoo
  • 2,492
  • 1
  • 21
  • 22
  • Changed it to md5 and it still doesn't work. Trust should accept any input – cp151 Oct 14 '12 at 14:03
  • Please also try to change from `ident` to `md5` in the `# IPv4 local connections` line. – arturhoo Oct 14 '12 at 14:06
  • I can connect via the command line and insert data into the database using psql -U question. I also tried to change from ident to md5 the IPV4 connections – cp151 Oct 14 '12 at 14:16
0

Have you tried changing:

host    all             all             127.0.0.1/32            ident

to:

host    all             all             127.0.0.1/32            md5

It appears that you are connecting via TCP (so the first line in pg_hba.confg with "trust" doesn't apply) and authenticate via ident, which requires entries in pg_ident.conf. You probably want "md5" or one of the other password-based authentication options.

Smith
  • 361
  • 1
  • 10