psql: FATAL: Ident authentication failed for user "root"

Kanishka Panamaldeniya picture Kanishka Panamaldeniya · Aug 8, 2014 · Viewed 9.2k times · Source

Hi i am using postgresql .

my

Postgres User : postgres 
Passwprd : abc123

but when i type root@xxxx:~#psql -U postgres -W

it says

   root@xxxx:~#   Ident authentication failed for user "root"

but when i su postgres cd and then type following command

#psql -U postgres -W

it is working correctly and i can access to all databases .

when i try to access my site it gives me the error in posstgres error log

password authentication failed for user "postgres"

why is this happening , please help me , thanks in advance

UPDATE

my pg_hba.conf

# Database administrative login by Unix domain socket
local   all             postgres                                trust

# TYPE  DATABASE    USER        CIDR-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          trust
# IPv6 local connections:
host    all         all         ::1/128               md5

Answer

Vivek S. picture Vivek S. · Aug 8, 2014

You have to create a role name root

create role root login