I have postgresql up and running on centos 6.5. The version I'm running is 9.3. Currently I have a python script that uses psycopg2 to insert data into a databse in postgresql called "testdb". When I try to run it on the server I run into this error:
Traceback (most recent call last):
File "collector2.py", line 10, in <module>
con = psycopg2.connect(database='testdb', host = 'localhost', user = 'foo', password = '12345')
File "/usr/lib64/python2.6/site-packages/psycopg2/__init__.py", line 164, in connect
conn = _connect(dsn, connection_factory=connection_factory, async=async)
psycopg2.OperationalError: FATAL: Ident authentication failed for user "foo"
This is my pg_hba.conf file. I can not understand whats wrong.
#TYPE DATABASE USER ADDRESS METHOD
local all postgres peer
# "local" is for Unix domain socket connections only
local all all peer
local all all ident
local testdb foo peer
# IPv4 local connections:
host all all 127.0.0.1/32 ident
# IPv6 local connections:
host all all ::1/128 ident
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication postgres peer
#host replication postgres 127.0.0.1/32 ident
#host replication postgres ::1/128 ident
I have given user 'foo' full priveleges on testdb.
su postgresand the problem solved.