Skip site navigation (1) Skip section navigation (2)

login error - Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: password authentication failed for user "kamik"

From: Jaromír Kamler <kamler(at)centrum(dot)cz>
To: pgsql-novice <pgsql-novice(at)postgresql(dot)org>
Subject: login error - Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: password authentication failed for user "kamik"
Date: 2010-11-12 21:02:37
Message-ID: 1289595757.291891.10263.nullmailer@mail1002.cent (view raw or flat)
Thread:
Lists: pgsql-novice
Hi guys,
I am trying connect to Postgres by PHP. I have this PHP code:
 

But web browser writes this error:
Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL:  password authentication failed for user "***" FATAL:  password authentication failed for user "***" in /var/www/test/index.php on line 6  Warning: pg_last_error(): No PostgreSQL link opened yet in /var/www/test/index.php on line 7 Could not connect: 

Main problem is that I have bad authentication for my user. In my pg_hba.conf is this:
# Database administrative login by UNIX sockets
local   all         postgres                          ident
# 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
host    all         all         0.0.0.0/0             md5
hostssl all         all         0.0.0.0/0             md5
hostnossl all       all         0.0.0.0/0             md5
# IPv6 local connections:
host    all         all         ::1/128               md5

And in postgresql.conf I set listen_addresses = "*"

When I delete in PHP script in pg_connect host="localhost", then all works fine, because I use UNIX domain socket (I am thinging ...), but when I use "normal" connection, it is wrong. Interesting is that phppgadmin works fine ... .

So, question is what I do wrong. I thing that I have mistake in pg_hba.conf, but I am blind. I have postgresql-8.4



Best regards

J.K.

Responses

pgsql-novice by date

Next:From: Tom LaneDate: 2010-11-12 21:07:39
Subject: Re: login error - Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: password authentication failed for user "kamik"
Previous:From: Steve CrawfordDate: 2010-11-12 21:01:18
Subject: Re: Postgres Wishlist

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group