Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

My settings:

  • Ubuntu 9.10
  • PostgreSQL 8.4.2

I created a new user(jdoe) under my local PostgreSQL with the following command in the psql shell:

CREATE USER jdoe WITH PASSWORD 'password';

I also have created a new database called mydb. My goal is to give user jdoe full access to database mydb. I did a few things through the GUI pgAdmin III and after running \l in the psql shell, I get the following output:

                                    List of databases
Name     |  Owner   | Encoding |  Collation  |    Ctype    |   Access privileges
--------------+----------+----------+-------------+-------------+---------------
mydb     | jdoe     | UTF8     | en_CA.UTF-8 | en_CA.UTF-8 | =CTc/mydb
                                                           : hmart=CTc/mydb
postgres | postgres | UTF8     | en_CA.UTF-8 | en_CA.UTF-8 | 

Showing my list of users(\du), I get:

            List of roles
 Role name | Attributes  | Member of 
-----------+-------------+-----------
 jdoe      |             | {}
 postgres  | Superuser   | {}
           : Create role   
           : Create DB    

I can't really tell from the above if my goal has been achieved, but is there a way to test if the user jdoe can communicate with the database mydb? I'm testing it though Django's settings:

DATABASE_ENGINE = 'postgresql_psycopg2'           
DATABASE_NAME = 'mydb'      
DATABASE_USER = 'jdoe'       
DATABASE_PASSWORD = 'password'        
DATABASE_HOST = ''         
DATABASE_PORT = '' 

but I'm getting the following error after a python manage.py syncdb:

psycopg2.OperationalError: FATAL:  Ident authentication failed for user "jdoe"

I did all the above on Win XP with the latest PostgreSQL installer and everything work flawlessly with Django. I'm not sure what I'm missing under Ubuntu.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

You probably have set it up in pg_hba.conf so that local socket connections must use ident authorization, while tcp connections to localhost are trusted. Read the documentation on pg_hba.conf for your version, eg 8.4 is here, and you can configure it correctly for your situation.

share|improve this answer

This is weird, setting DATABASE_HOST to localhost fix the issue:

# settings.py
DATABASE_HOST = 'localhost'
share|improve this answer
    
See above re pg_hba and tcp sockets vs unix domain sockets. –  Tobu Jun 29 '10 at 11:54
    
For some very strange reason this solved the problem for me –  Sevenearths Feb 14 '12 at 12:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.