php password authentication failed for user ...

Lists: pgsql-general
From: basti <mailinglist(at)unix-solution(dot)de>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: php password authentication failed for user ...
Date: 2014-07-09 11:04:19
Message-ID: 53BD21B3.7040307@unix-solution.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hello my pg_hab.conf has this entry:

host all all 127.0.0.1/32 md5

When I try to use PHP to connect to the Database I get

"postgres password authentication failed for user ..."

The PHP-code looks like

global $dbhost, $dbuser, $dbpass, $dbname, $use_pgsql, $dbconn;

if ($use_pgsql)
{
$connect = "host=$dbhost user=$dbuser password=$dbpass
dbname=$dbname";
echo $connect;
if (!($dbconn = pg_connect($connect)))
{
open_page();
ErrSQL("Unable to connect to database.");
}

When I try to connect via
psql -U user -h localhost -W database
I can connect without error.

I also use SSL connections, is this the problem? or in other words is
there a way to connect php via (postgres) ssl?

Regards,
basti


From: Bill Moran <wmoran(at)potentialtech(dot)com>
To: basti <mailinglist(at)unix-solution(dot)de>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: php password authentication failed for user ...
Date: 2014-07-09 11:14:32
Message-ID: 20140709071432.ec700ad41288c3972ecbe4cb@potentialtech.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Wed, 09 Jul 2014 13:04:19 +0200 basti <mailinglist(at)unix-solution(dot)de> wrote:

> Hello my pg_hab.conf has this entry:
>
> host all all 127.0.0.1/32 md5
>
> When I try to use PHP to connect to the Database I get
>
> "postgres password authentication failed for user ..."
>
> The PHP-code looks like
>
>
> global $dbhost, $dbuser, $dbpass, $dbname, $use_pgsql, $dbconn;
>
> if ($use_pgsql)
> {
> $connect = "host=$dbhost user=$dbuser password=$dbpass
> dbname=$dbname";
> echo $connect;
> if (!($dbconn = pg_connect($connect)))
> {
> open_page();
> ErrSQL("Unable to connect to database.");
> }
>
> When I try to connect via
> psql -U user -h localhost -W database
> I can connect without error.
>
> I also use SSL connections, is this the problem? or in other words is
> there a way to connect php via (postgres) ssl?

Have you tried using sslmode or requiressl in the $connect string?

--
Bill Moran <wmoran(at)potentialtech(dot)com>


From: Francisco Olarte <folarte(at)peoplecall(dot)com>
To: basti <mailinglist(at)unix-solution(dot)de>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: php password authentication failed for user ...
Date: 2014-07-09 11:47:44
Message-ID: CA+bJJbyEOQ4bXu9FLJ=KQGw0fwY538WwHaCyKtEbb5627j8y5w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hi:

On Wed, Jul 9, 2014 at 1:04 PM, basti <mailinglist(at)unix-solution(dot)de> wrote:
> Hello my pg_hab.conf has this entry:
> host all all 127.0.0.1/32 md5
....
> global $dbhost, $dbuser, $dbpass, $dbname, $use_pgsql, $dbconn;
...
> $connect = "host=$dbhost user=$dbuser password=$dbpass
> dbname=$dbname";
...
> When I try to connect via
> psql -U user -h localhost -W database

Which is the value of $dbhost ? is it localhost, to be coherent with
your psql line? ( or the output of the echo you put in the sample
script? )

If $dbhost is not localhost a name which resolves to 127.0.0.1 or a
literal 127.0.0.1 you are not getting in ( if the machine is 3.4.5.6
and you connect to machine.name.com which resolves to 3.4.5.6 your
usually get this kind of problems.

Francisco Olarte.


From: basti <mailinglist(at)unix-solution(dot)de>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: php password authentication failed for user ...
Date: 2014-07-09 12:01:32
Message-ID: 53BD2F1C.5080104@unix-solution.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Yes, there is the same problem.
postgres logs also:

"Connection matched pg_hba.conf line 93
„host all all 127.0.0.1/32 md5“"

Am 09.07.2014 13:14, schrieb Bill Moran:
> On Wed, 09 Jul 2014 13:04:19 +0200 basti <mailinglist(at)unix-solution(dot)de> wrote:
>
>> Hello my pg_hab.conf has this entry:
>>
>> host all all 127.0.0.1/32 md5
>>
>> When I try to use PHP to connect to the Database I get
>>
>> "postgres password authentication failed for user ..."
>>
>> The PHP-code looks like
>>
>>
>> global $dbhost, $dbuser, $dbpass, $dbname, $use_pgsql, $dbconn;
>>
>> if ($use_pgsql)
>> {
>> $connect = "host=$dbhost user=$dbuser password=$dbpass
>> dbname=$dbname";
>> echo $connect;
>> if (!($dbconn = pg_connect($connect)))
>> {
>> open_page();
>> ErrSQL("Unable to connect to database.");
>> }
>>
>> When I try to connect via
>> psql -U user -h localhost -W database
>> I can connect without error.
>>
>> I also use SSL connections, is this the problem? or in other words is
>> there a way to connect php via (postgres) ssl?
>
> Have you tried using sslmode or requiressl in the $connect string?
>


From: basti <mailinglist(at)unix-solution(dot)de>
To:
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: php password authentication failed for user ...
Date: 2014-07-09 12:04:25
Message-ID: 53BD2FC9.50501@unix-solution.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Here is the output of the echo.

host=127.0.0.1 user=mydns password=mypass sslmode=allow dbname=mydns

I have also try host=localhost and sslmode=require

Am 09.07.2014 13:47, schrieb Francisco Olarte:
> Hi:
>
> On Wed, Jul 9, 2014 at 1:04 PM, basti <mailinglist(at)unix-solution(dot)de> wrote:
>> Hello my pg_hab.conf has this entry:
>> host all all 127.0.0.1/32 md5
> ....
>> global $dbhost, $dbuser, $dbpass, $dbname, $use_pgsql, $dbconn;
> ...
>> $connect = "host=$dbhost user=$dbuser password=$dbpass
>> dbname=$dbname";
> ...
>> When I try to connect via
>> psql -U user -h localhost -W database
>
> Which is the value of $dbhost ? is it localhost, to be coherent with
> your psql line? ( or the output of the echo you put in the sample
> script? )
>
> If $dbhost is not localhost a name which resolves to 127.0.0.1 or a
> literal 127.0.0.1 you are not getting in ( if the machine is 3.4.5.6
> and you connect to machine.name.com which resolves to 3.4.5.6 your
> usually get this kind of problems.
>
> Francisco Olarte.
>


From: basti <basti(at)unix-solution(dot)de>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: php password authentication failed for user ...
Date: 2014-07-09 12:37:23
Message-ID: 53BD3783.8040206@unix-solution.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

I don't know whats wrong there
host mydns mydns localhost trust
works well and

#host all all 0.0.0.0 0.0.0.0 md5
did not work.

I use Postgres 9.3.4-1.pgdg70+1.

Am 09.07.2014 14:04, schrieb basti:
> Here is the output of the echo.
>
> host=127.0.0.1 user=mydns password=mypass sslmode=allow dbname=mydns
>
> I have also try host=localhost and sslmode=require
>
>
> Am 09.07.2014 13:47, schrieb Francisco Olarte:
>> Hi:
>>
>> On Wed, Jul 9, 2014 at 1:04 PM, basti <mailinglist(at)unix-solution(dot)de> wrote:
>>> Hello my pg_hab.conf has this entry:
>>> host all all 127.0.0.1/32 md5
>> ....
>>> global $dbhost, $dbuser, $dbpass, $dbname, $use_pgsql, $dbconn;
>> ...
>>> $connect = "host=$dbhost user=$dbuser password=$dbpass
>>> dbname=$dbname";
>> ...
>>> When I try to connect via
>>> psql -U user -h localhost -W database
>>
>> Which is the value of $dbhost ? is it localhost, to be coherent with
>> your psql line? ( or the output of the echo you put in the sample
>> script? )
>>
>> If $dbhost is not localhost a name which resolves to 127.0.0.1 or a
>> literal 127.0.0.1 you are not getting in ( if the machine is 3.4.5.6
>> and you connect to machine.name.com which resolves to 3.4.5.6 your
>> usually get this kind of problems.
>>
>> Francisco Olarte.
>>
>
>


From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: basti <mailinglist(at)unix-solution(dot)de>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: php password authentication failed for user ...
Date: 2014-07-09 13:06:08
Message-ID: 53BD3E40.3050903@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On 07/09/2014 04:04 AM, basti wrote:
> Hello my pg_hab.conf has this entry:
>
> host all all 127.0.0.1/32 md5

Is that the only entry?

If not remember first matching entry wins, so is there another line
above this?

>
> When I try to use PHP to connect to the Database I get
>
> "postgres password authentication failed for user ..."

Is the password correct?

>
> The PHP-code looks like
>
>
> global $dbhost, $dbuser, $dbpass, $dbname, $use_pgsql, $dbconn;
>
> if ($use_pgsql)
> {
> $connect = "host=$dbhost user=$dbuser password=$dbpass
> dbname=$dbname";
> echo $connect;
> if (!($dbconn = pg_connect($connect)))
> {
> open_page();
> ErrSQL("Unable to connect to database.");
> }
>
> When I try to connect via
> psql -U user -h localhost -W database
> I can connect without error.
>
> I also use SSL connections, is this the problem? or in other words is
> there a way to connect php via (postgres) ssl?

From:

http://www.postgresql.org/docs/9.3/interactive/auth-pg-hba-conf.html

host

This record matches connection attempts made using TCP/IP. host
records match either SSL or non-SSL connection attempts.

>
> Regards,
> basti
>
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com


From: basti <mailinglist(at)unix-solution(dot)de>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: php password authentication failed for user ...
Date: 2014-07-09 13:10:55
Message-ID: 53BD3F5F.3030208@unix-solution.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

There are other entrys in pg_hab.conf and yes the passwd is correct.
(psql -p ... -h ... from command line runs well).

I don't know whats wrong there
host mydns mydns localhost trust
works well and

#host all all 0.0.0.0 0.0.0.0 md5
did not work.

I use Postgres 9.3.4-1.pgdg70+1. (debian)

Am 09.07.2014 15:06, schrieb Adrian Klaver:
> On 07/09/2014 04:04 AM, basti wrote:
>> Hello my pg_hab.conf has this entry:
>>
>> host all all 127.0.0.1/32 md5
>
> Is that the only entry?
>
> If not remember first matching entry wins, so is there another line
> above this?
>
>>
>> When I try to use PHP to connect to the Database I get
>>
>> "postgres password authentication failed for user ..."
>
> Is the password correct?
>
>>
>> The PHP-code looks like
>>
>>
>> global $dbhost, $dbuser, $dbpass, $dbname, $use_pgsql, $dbconn;
>>
>> if ($use_pgsql)
>> {
>> $connect = "host=$dbhost user=$dbuser password=$dbpass
>> dbname=$dbname";
>> echo $connect;
>> if (!($dbconn = pg_connect($connect)))
>> {
>> open_page();
>> ErrSQL("Unable to connect to database.");
>> }
>>
>> When I try to connect via
>> psql -U user -h localhost -W database
>> I can connect without error.
>>
>> I also use SSL connections, is this the problem? or in other words is
>> there a way to connect php via (postgres) ssl?
>
> From:
>
> http://www.postgresql.org/docs/9.3/interactive/auth-pg-hba-conf.html
>
> host
>
> This record matches connection attempts made using TCP/IP. host
> records match either SSL or non-SSL connection attempts.
>
>
>>
>> Regards,
>> basti
>>
>>
>
>


From: rob stone <floriparob(at)gmail(dot)com>
To: basti <mailinglist(at)unix-solution(dot)de>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: php password authentication failed for user ...
Date: 2014-07-09 13:19:48
Message-ID: 1404911988.2443.18.camel@roblaptop.virtua.com.br
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Wed, 2014-07-09 at 14:01 +0200, basti wrote:
> Yes, there is the same problem.
> postgres logs also:
>
> "Connection matched pg_hba.conf line 93
> „host all all 127.0.0.1/32 md5“"
>
> Am 09.07.2014 13:14, schrieb Bill Moran:
> > On Wed, 09 Jul 2014 13:04:19 +0200 basti <mailinglist(at)unix-solution(dot)de> wrote:
> >
> >> Hello my pg_hab.conf has this entry:
> >>
> >> host all all 127.0.0.1/32 md5
> >>
> >> When I try to use PHP to connect to the Database I get
> >>
> >> "postgres password authentication failed for user ..."
> >>
> >> The PHP-code looks like
> >>
> >>
> >> global $dbhost, $dbuser, $dbpass, $dbname, $use_pgsql, $dbconn;
> >>
> >> if ($use_pgsql)
> >> {
> >> $connect = "host=$dbhost user=$dbuser password=$dbpass
> >> dbname=$dbname";
> >> echo $connect;
> >> if (!($dbconn = pg_connect($connect)))
> >> {
> >> open_page();
> >> ErrSQL("Unable to connect to database.");
> >> }
> >>
> >> When I try to connect via
> >> psql -U user -h localhost -W database
> >> I can connect without error.
> >>
> >> I also use SSL connections, is this the problem? or in other words is
> >> there a way to connect php via (postgres) ssl?
> >
> > Have you tried using sslmode or requiressl in the $connect string?
> >
>
>

You need to use "sslmode=require".

Are you encrypting the password? If not, alter the pg_hba.conf file to
"trust" instead of md5. If it's all running on localhost it's no big
deal.

Is the postgresql.conf file and your Apache config file in the
sites-available path compatible with SSL usage?

HTH
Robert


From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: basti <mailinglist(at)unix-solution(dot)de>, pgsql-general(at)postgresql(dot)org
Subject: Re: php password authentication failed for user ...
Date: 2014-07-09 13:23:06
Message-ID: 53BD423A.9080606@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On 07/09/2014 06:10 AM, basti wrote:
> There are other entrys in pg_hab.conf and yes the passwd is correct.

So what are the other entries and where are they relative to the line
that you think is causing the problem?

> (psql -p ... -h ... from command line runs well).

In your first post you showed this:

psql -U user -h localhost -W database

The password supplied here could come from a .pgpass file or env
variable so it does not necessarily mean that the same password is being
used that is used in the script.

>
> I don't know whats wrong there
> host mydns mydns localhost trust
> works well and

Well no password is being asked for in the above.

>
> #host all all 0.0.0.0 0.0.0.0 md5
> did not work.

In you original post you have as the problem line:

host all all 127.0.0.1/32 md5

Have you tried both?

Just to be certain, have you done pg_ctl reload after each change?

>
> I use Postgres 9.3.4-1.pgdg70+1. (debian)
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com


From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: rob stone <floriparob(at)gmail(dot)com>, basti <mailinglist(at)unix-solution(dot)de>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: php password authentication failed for user ...
Date: 2014-07-09 13:30:16
Message-ID: 53BD43E8.5090508@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On 07/09/2014 06:19 AM, rob stone wrote:
>
>
>

>
> You need to use "sslmode=require".
>
> Are you encrypting the password? If not, alter the pg_hba.conf file to
> "trust" instead of md5. If it's all running on localhost it's no big
> deal.

AFAIK PHP, in the connect function, takes care of encrypting the
password for you.

>
> Is the postgresql.conf file and your Apache config file in the
> sites-available path compatible with SSL usage?
>
> HTH
> Robert
>
>
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com


From: basti <mailinglist(at)unix-solution(dot)de>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: php password authentication failed for user ...
Date: 2014-07-09 13:32:20
Message-ID: 53BD4464.2000509@unix-solution.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Is there a simple md5 hash?
I also try to hash my passwd via md5.
There is sill the same error.

Am 09.07.2014 15:19, schrieb rob stone:
> Are you encrypting the password? If not, alter the pg_hba.conf file to
> "trust" instead of md5. If it's all running on localhost it's no big
> deal.


From: Alban Hertroys <haramrae(at)gmail(dot)com>
To: basti <mailinglist(at)unix-solution(dot)de>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: php password authentication failed for user ...
Date: 2014-07-09 13:46:49
Message-ID: CAF-3MvM9CKsPvbo6ouKb17S7k9xRDfDwbZi24mp2jLaRv1XB_g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On 9 July 2014 15:10, basti <mailinglist(at)unix-solution(dot)de> wrote:
> There are other entrys in pg_hab.conf and yes the passwd is correct.
> (psql -p ... -h ... from command line runs well).

I do hope you're looking in a file named pg_hba.conf and not
pg_hab.conf? The latter is unknown to PG, you should throw that away
if it's there as it will only serve to confuse people.

--
If you can't see the forest for the trees,
Cut the trees and you'll see there is no forest.


From: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
To: basti <mailinglist(at)unix-solution(dot)de>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: php password authentication failed for user ...
Date: 2014-07-09 13:56:24
Message-ID: CAOR=d=3xoF1Wx_Nimz4uFJeXJRSiVj-sRs07VktdnTAK0aTTmg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Wed, Jul 9, 2014 at 5:04 AM, basti <mailinglist(at)unix-solution(dot)de> wrote:
> Hello my pg_hab.conf has this entry:
>
> host all all 127.0.0.1/32 md5
>
> When I try to use PHP to connect to the Database I get
>
> "postgres password authentication failed for user ..."
>
> The PHP-code looks like
>
>
> global $dbhost, $dbuser, $dbpass, $dbname, $use_pgsql, $dbconn;
>
> if ($use_pgsql)
> {
> $connect = "host=$dbhost user=$dbuser password=$dbpass
> dbname=$dbname";
> echo $connect;
> if (!($dbconn = pg_connect($connect)))
> {
> open_page();
> ErrSQL("Unable to connect to database.");
> }

This is not proper error handling. Use the pg_* functions that report
the actual error, not some string you made on your own.


From: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
To: basti <basti(at)unix-solution(dot)de>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: php password authentication failed for user ...
Date: 2014-07-10 03:21:39
Message-ID: CAOR=d=0on-D8KTpbfhLuXakUTvFdnLUa7zRLdUEjBnW5dVQUZA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Wed, Jul 9, 2014 at 6:37 AM, basti <basti(at)unix-solution(dot)de> wrote:
> I don't know whats wrong there
> host mydns mydns localhost trust
> works well and
>
> #host all all 0.0.0.0 0.0.0.0 md5
> did not work.
>
> I use Postgres 9.3.4-1.pgdg70+1.
>

PHP should be telling you what you're doing wrong. Look in your logs
etc. For example this code:

<?php
$conn = pg_connect("dbname=smarlowe host=localhost");
?>

on my box gives me this warning:

PHP Warning: pg_connect(): Unable to connect to PostgreSQL server:
fe_sendauth: no password supplied in /tmp/test.php on line 2


From: Francisco Olarte <folarte(at)peoplecall(dot)com>
To: basti <basti(at)unix-solution(dot)de>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: php password authentication failed for user ...
Date: 2014-07-10 11:53:46
Message-ID: CA+bJJbzGa1D-dYxHZkA=Ht1RfMxzNg1iZkHpz_TB4r2EVxMcpQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hi:

On Wed, Jul 9, 2014 at 2:37 PM, basti <basti(at)unix-solution(dot)de> wrote:
> I don't know whats wrong there
> host mydns mydns localhost trust
> works well and
> #host all all 0.0.0.0 0.0.0.0 md5
> did not work.

> I use Postgres 9.3.4-1.pgdg70+1.

Well, first line should be no password, user mydns, db mydns, host
localhost ( which USUALLY is 127.0.0.1 ), no credential checks, so if
you are not changing anything between ( or not showing the complete
file ) it means you have user, db, method ( tcp ) and origin host
right.

Second one is any user, any db, any IP, but checking password.

Giving that the only think the second line checks which the first one
does not, I'll vote for bad password in the script. I suppose php uses
libpq, like psql, so it should work. Anyway, check your paths and
constants, isolate changes, test. This kind of problems are imposible
to diagnose without much more info than what you are giving, and
normally due to mystyped constants.

Francisco Olarte.


From: Ken Tanzer <ken(dot)tanzer(at)gmail(dot)com>
To: basti <basti(at)unix-solution(dot)de>
Cc: PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: php password authentication failed for user ...
Date: 2014-07-10 12:03:10
Message-ID: CAD3a31XYwapVkDWT=hj9JtFooJ_WHrGx8wSoo5=gHOExvM=a5A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Wed, Jul 9, 2014 at 5:37 AM, basti <basti(at)unix-solution(dot)de> wrote:

> #host all all 0.0.0.0 0.0.0.0 md5
> did not work.
>
>
If it really starts with a # like you show it above, it's just a comment
and pretty much guaranteed not to do anything.

Cheers,
Ken

--
AGENCY Software
A Free Software data system
By and for non-profits
*http://agency-software.org/ <http://agency-software.org/>*
*https://agency-software.org/demo/client
<https://agency-software.org/demo/client>*
ken(dot)tanzer(at)agency-software(dot)org
(253) 245-3801

Subscribe to the mailing list
<agency-general-request(at)lists(dot)sourceforge(dot)net?body=subscribe> to
learn more about AGENCY or
follow the discussion.


From: basti <mailinglist(at)unix-solution(dot)de>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: php password authentication failed for user ...
Date: 2014-07-15 12:52:12
Message-ID: 53C523FC.9070605@unix-solution.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

The last days I have done some tests and it seems that postgres 9.3 and
php 5.4.4 can't work together.

Can someone please confirm:

<?php
$host = "localhost";
$port = "5432";
$user = "testuser";
$pass = "mypasswd";
$db = "testdb";

echo "postgres test</br>";
$con = pg_connect("host=$host port=$port dbname=$db user=$user
password=$pass")
or die ("Could not connect to server\n");
print_r($con);
?>

work well with
host all all localhost trust

in pg_hba.conf

When I use
host all all localhost md5

then I get the following error:

password authentication failed for user "testuser"
Connection matched pg_hba.conf line 89: "host all all
localhost md5"

I have the problem on several servers, installed

postgres: postgresql-9.3 (9.3.4-1.pgdg70+1),
postgresql-client-9.3(9.3.4-1.pgdg70+1),
postgresql-client-common(154.pgdg70+1), postgresql-common(154.pgdg70+1),
postgresql-contrib-9.3(9.3.4-1.pgdg70+1)
php: php5(5.4.4-14+deb7u12), libphp-adodb(5.15-1),
php5-pgsql(5.4.4-14+deb7u12)

When I try Postgres 9.1 and php 5.4.4 with md5 auth-method, it also
works very well.
Perhaps someone can do a bug report?

Thanks for any help!
Best regards,

basti

Am 10.07.2014 05:21, schrieb Scott Marlowe:
> On Wed, Jul 9, 2014 at 6:37 AM, basti <basti(at)unix-solution(dot)de> wrote:
>> I don't know whats wrong there
>> host mydns mydns localhost trust
>> works well and
>>
>> #host all all 0.0.0.0 0.0.0.0 md5
>> did not work.
>>
>> I use Postgres 9.3.4-1.pgdg70+1.
>>
>
> PHP should be telling you what you're doing wrong. Look in your logs
> etc. For example this code:
>
> <?php
> $conn = pg_connect("dbname=smarlowe host=localhost");
> ?>
>
> on my box gives me this warning:
>
> PHP Warning: pg_connect(): Unable to connect to PostgreSQL server:
> fe_sendauth: no password supplied in /tmp/test.php on line 2
>
>


From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: basti <mailinglist(at)unix-solution(dot)de>, pgsql-general(at)postgresql(dot)org
Subject: Re: php password authentication failed for user ...
Date: 2014-07-15 14:00:06
Message-ID: 53C533E6.7030904@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On 07/15/2014 05:52 AM, basti wrote:
> The last days I have done some tests and it seems that postgres 9.3 and
> php 5.4.4 can't work together.

I find that hard to believe.

>
> Can someone please confirm:
>
> <?php
> $host = "localhost";
> $port = "5432";
> $user = "testuser";
> $pass = "mypasswd";
> $db = "testdb";
>
> echo "postgres test</br>";
> $con = pg_connect("host=$host port=$port dbname=$db user=$user
> password=$pass")
> or die ("Could not connect to server\n");
> print_r($con);
> ?>
>
> work well with
> host all all localhost trust

Again, no password is required and no authentication is done. The issue
would if this did not work.

>
> in pg_hba.conf
>
> When I use
> host all all localhost md5
>
> then I get the following error:
>
> password authentication failed for user "testuser"
> Connection matched pg_hba.conf line 89: "host all all
> localhost md5"

Is the line you think you are working with actually at line 89?

Do you have more than one instance of Postgres running?

In other words are you sure you are connecting to the correct cluster?

Per Scotts suggestion, what does the Postgres log say when attempt the
connection?

To confirm, when you connect with psql with the md5 line enabled you can
connect?

The reason I ask is that psql and PHP both use the libpq library to connect.

My money says you have an issue with the password/user/Postgres cluster
combination.

>
> I have the problem on several servers, installed

Where they set up by you or where they pre-installed?

>
> postgres: postgresql-9.3 (9.3.4-1.pgdg70+1),
> postgresql-client-9.3(9.3.4-1.pgdg70+1),
> postgresql-client-common(154.pgdg70+1), postgresql-common(154.pgdg70+1),
> postgresql-contrib-9.3(9.3.4-1.pgdg70+1)
> php: php5(5.4.4-14+deb7u12), libphp-adodb(5.15-1),
> php5-pgsql(5.4.4-14+deb7u12)

I notice you have adodb installed.
Are you using it when you try to connect above?

>
> When I try Postgres 9.1 and php 5.4.4 with md5 auth-method, it also
> works very well.
> Perhaps someone can do a bug report?

You can do that below, though at this point I do not think there is
enough information to reach a conclusion.

http://www.postgresql.org/support/submitbug/

>
> Thanks for any help!
> Best regards,
>
> basti
>
>
> Am 10.07.2014 05:21, schrieb Scott Marlowe:
>> On Wed, Jul 9, 2014 at 6:37 AM, basti <basti(at)unix-solution(dot)de> wrote:
>>> I don't know whats wrong there
>>> host mydns mydns localhost trust
>>> works well and
>>>
>>> #host all all 0.0.0.0 0.0.0.0 md5
>>> did not work.
>>>
>>> I use Postgres 9.3.4-1.pgdg70+1.
>>>
>>
>> PHP should be telling you what you're doing wrong. Look in your logs
>> etc. For example this code:
>>
>> <?php
>> $conn = pg_connect("dbname=smarlowe host=localhost");
>> ?>
>>
>> on my box gives me this warning:
>>
>> PHP Warning: pg_connect(): Unable to connect to PostgreSQL server:
>> fe_sendauth: no password supplied in /tmp/test.php on line 2
>>
>>
>
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com


From: basti <mailinglist(at)unix-solution(dot)de>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: php password authentication failed for user ...
Date: 2014-07-15 14:17:29
Message-ID: 53C537F9.8030701@unix-solution.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hello Adrian,

Yes I use the correct cluster.

password authentication failed for user "testuser" ...
is a line from the postgres log

Yes I know what "trust" mean.

psql in version 9.3 can connect without error,
psql in version 9.1 connect to server 9.3 get the same error as above.

I have done the setup.
And I don't use ADO for this test.

I have also test

Postgres 9.1 and Postgres 9.4 both work with auth-method md5, except
postgres 9.3 discuss there.

It takes a round 5 hours to find this "error".
If anybody has the same problem be warned.

Regards,
basti

Am 15.07.2014 16:00, schrieb Adrian Klaver:
> On 07/15/2014 05:52 AM, basti wrote:
>> The last days I have done some tests and it seems that postgres 9.3 and
>> php 5.4.4 can't work together.
>
> I find that hard to believe.
>
>>
>> Can someone please confirm:
>>
>> <?php
>> $host = "localhost";
>> $port = "5432";
>> $user = "testuser";
>> $pass = "mypasswd";
>> $db = "testdb";
>>
>> echo "postgres test</br>";
>> $con = pg_connect("host=$host port=$port dbname=$db user=$user
>> password=$pass")
>> or die ("Could not connect to server\n");
>> print_r($con);
>> ?>
>>
>> work well with
>> host all all localhost trust
>
> Again, no password is required and no authentication is done. The issue
> would if this did not work.
>
>>
>> in pg_hba.conf
>>
>> When I use
>> host all all localhost md5
>>
>> then I get the following error:
>>
>> password authentication failed for user "testuser"
>> Connection matched pg_hba.conf line 89: "host all all
>> localhost md5"
>
> Is the line you think you are working with actually at line 89?
>
> Do you have more than one instance of Postgres running?
>
> In other words are you sure you are connecting to the correct cluster?
>
> Per Scotts suggestion, what does the Postgres log say when attempt the
> connection?
>
> To confirm, when you connect with psql with the md5 line enabled you can
> connect?
>
> The reason I ask is that psql and PHP both use the libpq library to
> connect.
>
> My money says you have an issue with the password/user/Postgres cluster
> combination.
>
>>
>> I have the problem on several servers, installed
>
> Where they set up by you or where they pre-installed?
>
>>
>> postgres: postgresql-9.3 (9.3.4-1.pgdg70+1),
>> postgresql-client-9.3(9.3.4-1.pgdg70+1),
>> postgresql-client-common(154.pgdg70+1), postgresql-common(154.pgdg70+1),
>> postgresql-contrib-9.3(9.3.4-1.pgdg70+1)
>> php: php5(5.4.4-14+deb7u12), libphp-adodb(5.15-1),
>> php5-pgsql(5.4.4-14+deb7u12)
>
> I notice you have adodb installed.
> Are you using it when you try to connect above?
>
>>
>> When I try Postgres 9.1 and php 5.4.4 with md5 auth-method, it also
>> works very well.
>> Perhaps someone can do a bug report?
>
> You can do that below, though at this point I do not think there is
> enough information to reach a conclusion.
>
> http://www.postgresql.org/support/submitbug/
>
>>
>> Thanks for any help!
>> Best regards,
>>
>> basti
>>
>>
>> Am 10.07.2014 05:21, schrieb Scott Marlowe:
>>> On Wed, Jul 9, 2014 at 6:37 AM, basti <basti(at)unix-solution(dot)de> wrote:
>>>> I don't know whats wrong there
>>>> host mydns mydns localhost trust
>>>> works well and
>>>>
>>>> #host all all 0.0.0.0 0.0.0.0
>>>> md5
>>>> did not work.
>>>>
>>>> I use Postgres 9.3.4-1.pgdg70+1.
>>>>
>>>
>>> PHP should be telling you what you're doing wrong. Look in your logs
>>> etc. For example this code:
>>>
>>> <?php
>>> $conn = pg_connect("dbname=smarlowe host=localhost");
>>> ?>
>>>
>>> on my box gives me this warning:
>>>
>>> PHP Warning: pg_connect(): Unable to connect to PostgreSQL server:
>>> fe_sendauth: no password supplied in /tmp/test.php on line 2
>>>
>>>
>>
>>
>
>


From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: basti <mailinglist(at)unix-solution(dot)de>, pgsql-general(at)postgresql(dot)org
Subject: Re: php password authentication failed for user ...
Date: 2014-07-15 14:33:57
Message-ID: 53C53BD5.8040803@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On 07/15/2014 07:17 AM, basti wrote:
> Hello Adrian,
>
> Yes I use the correct cluster.
>
> password authentication failed for user "testuser" ...
> is a line from the postgres log
>
> Yes I know what "trust" mean.
>
> psql in version 9.3 can connect without error,
> psql in version 9.1 connect to server 9.3 get the same error as above.

That would seem to indicate that you have a version issue with libpq.

What does dkpg show for installed versions of libpq?

>
> I have done the setup.
> And I don't use ADO for this test.
>
> I have also test
>
> Postgres 9.1 and Postgres 9.4 both work with auth-method md5, except
> postgres 9.3 discuss there.
>
> It takes a round 5 hours to find this "error".

What exactly does that mean?

> If anybody has the same problem be warned.
>
> Regards,
> basti
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com


From: basti <basti(at)unix-solution(dot)de>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: php password authentication failed for user ...
Date: 2014-07-15 14:43:27
Message-ID: 53C53E0F.6060700@unix-solution.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

psql in version 9.1 connect to server 9.3 get the same error as above.
=>
dpkg -l | grep libpq
ii libpq5 9.1.13-0wheezy1
amd64 PostgreSQL C client library

the other I cant say, now thats
ii libpq5:amd64 9.4~beta1-2.pgdg70+1
amd64 PostgreSQL C client library

Am 15.07.2014 16:33, schrieb Adrian Klaver:
> On 07/15/2014 07:17 AM, basti wrote:
>> Hello Adrian,
>>
>> Yes I use the correct cluster.
>>
>> password authentication failed for user "testuser" ...
>> is a line from the postgres log
>>
>> Yes I know what "trust" mean.
>>
>> psql in version 9.3 can connect without error,
>> psql in version 9.1 connect to server 9.3 get the same error as above.
>
> That would seem to indicate that you have a version issue with libpq.
>
> What does dkpg show for installed versions of libpq?
>
>>
>> I have done the setup.
>> And I don't use ADO for this test.
>>
>> I have also test
>>
>> Postgres 9.1 and Postgres 9.4 both work with auth-method md5, except
>> postgres 9.3 discuss there.
>>
>> It takes a round 5 hours to find this "error".
>
> What exactly does that mean?
>
>> If anybody has the same problem be warned.
>>
>> Regards,
>> basti
>>
>
>


From: basti <mailinglist(at)unix-solution(dot)de>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: php password authentication failed for user ...
Date: 2014-07-15 14:45:17
Message-ID: 53C53E7D.6040102@unix-solution.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

psql in version 9.1 connect to server 9.3 get the same error as above.
=>
dpkg -l | grep libpq
ii libpq5 9.1.13-0wheezy1
amd64 PostgreSQL C client library

the other I cant say, now thats
ii libpq5:amd64 9.4~beta1-2.pgdg70+1
amd64 PostgreSQL C client library

Am 15.07.2014 16:33, schrieb Adrian Klaver:
> On 07/15/2014 07:17 AM, basti wrote:
>> Hello Adrian,
>>
>> Yes I use the correct cluster.
>>
>> password authentication failed for user "testuser" ...
>> is a line from the postgres log
>>
>> Yes I know what "trust" mean.
>>
>> psql in version 9.3 can connect without error,
>> psql in version 9.1 connect to server 9.3 get the same error as above.
>
> That would seem to indicate that you have a version issue with libpq.
>
> What does dkpg show for installed versions of libpq?
>
>>
>> I have done the setup.
>> And I don't use ADO for this test.
>>
>> I have also test
>>
>> Postgres 9.1 and Postgres 9.4 both work with auth-method md5, except
>> postgres 9.3 discuss there.
>>
>> It takes a round 5 hours to find this "error".
>
> What exactly does that mean?
>
>> If anybody has the same problem be warned.
>>
>> Regards,
>> basti
>>
>
>


From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: basti <mailinglist(at)unix-solution(dot)de>, pgsql-general(at)postgresql(dot)org
Subject: Re: php password authentication failed for user ...
Date: 2014-07-15 14:46:26
Message-ID: 53C53EC2.7080500@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On 07/15/2014 07:17 AM, basti wrote:
> Hello Adrian,
>
> Yes I use the correct cluster.
>
> password authentication failed for user "testuser" ...
> is a line from the postgres log
>
> Yes I know what "trust" mean.
>
> psql in version 9.3 can connect without error,
> psql in version 9.1 connect to server 9.3 get the same error as above.
>
> I have done the setup.
> And I don't use ADO for this test.
>
> I have also test
>
> Postgres 9.1 and Postgres 9.4 both work with auth-method md5, except
> postgres 9.3 discuss there.

To follow up on my previous post.

Are all these clusters running on the same machine?

Where they all installed from the same source, pgdg, or are they from
different sources?

I have to go, so I will get back to this later, though I suspect wiser
minds then mine will get you an answer in the interim.

>
> It takes a round 5 hours to find this "error".
> If anybody has the same problem be warned.
>
> Regards,
> basti
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com


From: "Daniel Verite" <daniel(at)manitou-mail(dot)org>
To: "basti" <mailinglist(at)unix-solution(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: php password authentication failed for user ...
Date: 2014-07-15 16:49:54
Message-ID: c943c3ea-0950-40d0-b2be-0e19251bc473@mm
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

basti wrote:

> host all all localhost md5
>
> then I get the following error:
>
> password authentication failed for user "testuser"

Aside from submitting a wrong password, a less obvious cause for this error
message is when the password is expired.

Not so long ago, there was an insidious bug in pgAdmin that caused the
password validity to be possibly set in the past when editing a user account.
This results in that "password authentication failed" error when trying to
connect with the correct password.

Here's the relevant changelog entry, from
http://www.pgadmin.org/development/changelog.php

2012-11-28 AV 1.16.1 Date picker controls returns a full timestamp by
default, which can cause inadvertent date changes
on jobs and role validty dates. Ignore the time part.

If you happen to use pgadmin, check its version and your problematic
account's validity ("valuntil" field in the pg_user view). Reset it if needed
with:

ALTER USER username VALID UNTIL 'infinity';

Best regards,
--
Daniel
PostgreSQL-powered mail user agent and storage: http://www.manitou-mail.org


From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: basti <mailinglist(at)unix-solution(dot)de>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: php password authentication failed for user ...
Date: 2014-07-15 20:34:22
Message-ID: 53C5904E.8000602@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On 07/15/2014 07:45 AM, basti wrote:
> psql in version 9.1 connect to server 9.3 get the same error as above.
> =>
> dpkg -l | grep libpq
> ii libpq5 9.1.13-0wheezy1
> amd64 PostgreSQL C client library
>
> the other I cant say, now thats
> ii libpq5:amd64 9.4~beta1-2.pgdg70+1
> amd64 PostgreSQL C client library
>
>

Well it looks like different sources for the packages.

I am not sure I am following your listings above.

Are they on the same machine?

What does ldd show for the various psql versions and the php extension
pgsql.so?

My suspicion is that the PHP extension and/or the Postgres 9.1 psql are
linked to the wrong file.

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com


From: basti <mailinglist(at)unix-solution(dot)de>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: php password authentication failed for user ...
Date: 2014-07-16 08:13:50
Message-ID: 53C6343E.5010201@unix-solution.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Yes all clusters, run on the same machine.
All packages are from pgdg.
libpq5 is version 9.3.4-1.pgdg70+1
the problem is still the same,
The relevant database is only for testing and development,
I will downgrade to 9.1.

Thanks for helping.

Regards,
basti

Am 15.07.2014 16:46, schrieb Adrian Klaver:
> On 07/15/2014 07:17 AM, basti wrote:
>> Hello Adrian,
>>
>> Yes I use the correct cluster.
>>
>> password authentication failed for user "testuser" ...
>> is a line from the postgres log
>>
>> Yes I know what "trust" mean.
>>
>> psql in version 9.3 can connect without error,
>> psql in version 9.1 connect to server 9.3 get the same error as above.
>>
>> I have done the setup.
>> And I don't use ADO for this test.
>>
>> I have also test
>>
>> Postgres 9.1 and Postgres 9.4 both work with auth-method md5, except
>> postgres 9.3 discuss there.
>
> To follow up on my previous post.
>
> Are all these clusters running on the same machine?
>
> Where they all installed from the same source, pgdg, or are they from
> different sources?
>
> I have to go, so I will get back to this later, though I suspect wiser
> minds then mine will get you an answer in the interim.
>
>>
>> It takes a round 5 hours to find this "error".
>> If anybody has the same problem be warned.
>>
>> Regards,
>> basti
>>
>
>


From: Marc Mamin <M(dot)Mamin(at)intershop(dot)de>
To: "'basti'" <mailinglist(at)unix-solution(dot)de>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: php password authentication failed for user ...
Date: 2014-07-16 09:36:52
Message-ID: B6F6FD62F2624C4C9916AC0175D56D8828AB0163@jenmbs01.ad.intershop.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

> -----Original Message-----
> From: pgsql-general-owner(at)postgresql(dot)org [mailto:pgsql-general-
> owner(at)postgresql(dot)org] On Behalf Of basti
> Sent: Mittwoch, 16. Juli 2014 10:14
> To: pgsql-general(at)postgresql(dot)org
> Subject: Re: [GENERAL] php password authentication failed for user ...
>
> Yes all clusters, run on the same machine.
> All packages are from pgdg.
> libpq5 is version 9.3.4-1.pgdg70+1
> the problem is still the same,
> The relevant database is only for testing and development, I will downgrade to
> 9.1.

Hello,
Did you already try to connect using the IP instead of "localhost" ?

regards,

Marc Mamin

>
> Thanks for helping.
>
> Regards,
> basti
>
> Am 15.07.2014 16:46, schrieb Adrian Klaver:
> > On 07/15/2014 07:17 AM, basti wrote:
> >> Hello Adrian,
> >>
> >> Yes I use the correct cluster.
> >>
> >> password authentication failed for user "testuser" ...
> >> is a line from the postgres log
> >>
> >> Yes I know what "trust" mean.
> >>
> >> psql in version 9.3 can connect without error, psql in version 9.1
> >> connect to server 9.3 get the same error as above.
> >>
> >> I have done the setup.
> >> And I don't use ADO for this test.
> >>
> >> I have also test
> >>
> >> Postgres 9.1 and Postgres 9.4 both work with auth-method md5, except
> >> postgres 9.3 discuss there.
> >
> > To follow up on my previous post.
> >
> > Are all these clusters running on the same machine?
> >
> > Where they all installed from the same source, pgdg, or are they from
> > different sources?
> >
> > I have to go, so I will get back to this later, though I suspect wiser
> > minds then mine will get you an answer in the interim.
> >
> >>
> >> It takes a round 5 hours to find this "error".
> >> If anybody has the same problem be warned.
> >>
> >> Regards,
> >> basti
> >>
> >
> >
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org) To make
> changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general


From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: basti <mailinglist(at)unix-solution(dot)de>, pgsql-general(at)postgresql(dot)org
Subject: Re: php password authentication failed for user ...
Date: 2014-07-16 14:46:45
Message-ID: 53C69055.7010906@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On 07/16/2014 01:13 AM, basti wrote:
> Yes all clusters, run on the same machine.
> All packages are from pgdg.
> libpq5 is version 9.3.4-1.pgdg70+1

That is not what a previous post indicated:

"dpkg -l | grep libpq
ii libpq5 9.1.13-0wheezy1
amd64 PostgreSQL C client library"

> the problem is still the same,
> The relevant database is only for testing and development,
> I will downgrade to 9.1.

I have a feeling that is not going to solve what I think is the
underlying issue, you have a mixed source install of packages.

>
> Thanks for helping.
>
> Regards,
> basti
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com