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

Lists: pgsql-novice
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
Views: Raw Message | Whole Thread | Download mbox | Resend email
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.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jaromír Kamler <kamler(at)centrum(dot)cz>
Cc: pgsql-novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: login error - Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: password authentication failed for user "kamik"
Date: 2010-11-12 21:07:39
Message-ID: 2315.1289596059@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

=?UTF-8?B?SmFyb23DrXIgS2FtbGVy?= <kamler(at)centrum(dot)cz> writes:
> 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:

What it looks like is your script isn't supplying the right password.

> When I delete in PHP script in pg_connect host="localhost", then all
> works fine, because I use UNIX domain socket (I am thinging ...),

You've got auth method set to "trust" for local connections, so in that
case it's not going to matter whether the script has the right password.

regards, tom lane


From: LazyTrek <lazytrek(at)gmail(dot)com>
To: Jaromír Kamler <kamler(at)centrum(dot)cz>
Cc: pgsql-novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: login error - Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: password authentication failed for user "kamik"
Date: 2010-11-12 21:23:53
Message-ID: AANLkTikNN1xnmWGCO5n098t7Rqa44rX_a73OfvUQTcEs@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

Just a quick obvious check - can you ping localhost?

2010/11/12 Jaromír Kamler <kamler(at)centrum(dot)cz>

>
> 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.
>
> --
> Sent via pgsql-novice mailing list (pgsql-novice(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-novice
>


From: LazyTrek <lazytrek(at)gmail(dot)com>
To: Jaromír Kamler <kamler(at)centrum(dot)cz>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: login error - Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: password authentication failed for user "kamik"
Date: 2010-11-12 22:40:20
Message-ID: AANLkTikVuwtTfaCq6xD6h7A=15-Prw-F527AkCuEUM09@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

Odd - can't explain that. I've just tried creating a new user with the
syntax you used and it worked fine when connecting in afterwards.

The only possible explanation I can think of is a typo when you created the
original password (or CAPS etc) or possibly a difference in the character
set between the command line createuser executable and psql (I'm clutching
at straws though).

I personally avoid the command line utilities and do everything through
psql. Not to say they shouldn't work reliably though.

Glad its working now though!

2010/11/12 Jaromír Kamler <kamler(at)centrum(dot)cz>

> Thanks for reply, that is it. I altered user, set same password and it
> works!!! Why? I can not understand it. My user postgis was created by user
> postgres by command createuser postgis -s -d -P -E and then I typed the same
> pwd like now. I still do not know where was problem. Any ideas? I know that
> it is not much important now, but for better understanding PostgreSQL it is
> good to know.
>
>
> Best regards
>
> Jaromir Kamler
>
> ______________________________________________________________
> > Od: "LazyTrek" <lazytrek(at)gmail(dot)com>
> > Komu: Jaromír Kamler <kamler(at)centrum(dot)cz>
> > Datum: 12.11.2010 22:55
>
> > Předmět: Re: [NOVICE] login error - Warning: pg_connect(): Unable to
> connect to PostgreSQL server: FATAL: password authentication failed for user
> "kamik"
> >
> Jaromir,
>
> I'm a novice myself so apologies if I'm of no help but I thought I'd try.
>
> I've just tested your pg_hba.conf with a test database. I hit problems too
> where the user was not set up with a password but the UNIX login would
> obviously still let it login.
>
> If you're willing to give something else a go, can you use a working method
> to connect to the database and issue the following -
>
> ALTER USER <user> encrypted password '<password>';
>
> Then reattempt the localhost connection string.
>
> Hope you don't mind another novice offering you advice but sometimes it
> just needs a second pair of eyes!
>
> 2010/11/12 Jaromír Kamler <kamler(at)centrum(dot)cz>
>
>> quick answer:
>> YES
>>
>> phppgadmin works, pgAdmin III works, PHP framework CodeIgniter works when
>> i set this $db['default']['hostname'] = ""; but when I set localhost, there
>> is problem.
>>
>> Regards
>> Jaromir Kamler
>>
>> ______________________________________________________________
>> > Od: "LazyTrek" <lazytrek(at)gmail(dot)com>
>> > Komu: Jaromír Kamler <kamler(at)centrum(dot)cz>
>> > Datum: 12.11.2010 22:24
>> > Předmět: Re: [NOVICE] login error - Warning: pg_connect(): Unable to
>> connect to PostgreSQL server: FATAL: password authentication failed for user
>> "kamik"
>>
>> >
>> Just a quick obvious check - can you ping localhost?
>>
>> 2010/11/12 Jaromír Kamler <kamler(at)centrum(dot)cz>
>>
>>>
>>> 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.
>>>
>>> --
>>> Sent via pgsql-novice mailing list (pgsql-novice(at)postgresql(dot)org)
>>> To make changes to your subscription:
>>> http://www.postgresql.org/mailpref/pgsql-novice
>>>
>>
>


From: Jasen Betts <jasen(at)xnet(dot)co(dot)nz>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: login error - Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: password authentication failed for user "kamik"
Date: 2010-11-15 18:18:38
Message-ID: ibrthu$707$2@reversiblemaps.ath.cx
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

On 2010-11-12, Jaromír Kamler <kamler(at)centrum(dot)cz> wrote:

>
> 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

> 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

what address is "localhost"?
I'm guessing it's not what you think it is.

--
⚂⚃ 100% natural