08 July 2010

Authentication failed

If you can't connect to postgres with the psql command (this happens, for example, with Ubuntu 9.10 and postgres 8.3):
$ psql -W gis username
psql: FATAL:  Ident authentication failed for user "username"
Even after you've set the password for the user:
$ sudo -u postgres -s -H
postgres@aoeu$ psql 
Welcome to psql 8.3.5, the PostgreSQL interactive terminal.
ALTER ROLE username PASSWORD 'mypassword';
You may have to append the following lines to your pg_hba.conf (found e.g. in /etc/postgresql/8.3/main):
local   all         all                               trust   
host    all         all          trust
host    all         all         ::1/128               trust
So that you can use password authentication from localhost.
Note that you may have to comment out any existing lines beginning with local all or host all. I had to comment out the following section on Ubuntu 8.40:
# "local" is for Unix domain socket connections only 
#local   all         all                               ident sameuser
# IPv4 local connections:
#host    all         all          md5
# IPv6 local connections:
#host    all         all         ::1/128               md5


Xiaoyu Guan (Sam)

No comments: