Thread: php password authentication failed for user ...

php password authentication failed for user ...

From
basti
Date:
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


Re: php password authentication failed for user ...

From
Bill Moran
Date:
On Wed, 09 Jul 2014 13:04:19 +0200 basti <mailinglist@unix-solution.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@potentialtech.com>


Re: php password authentication failed for user ...

From
Francisco Olarte
Date:
Hi:

On Wed, Jul 9, 2014 at 1:04 PM, basti <mailinglist@unix-solution.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.


Re: php password authentication failed for user ...

From
basti
Date:
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@unix-solution.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?
>


Re: php password authentication failed for user ...

From
basti
Date:
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@unix-solution.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.
>


Re: php password authentication failed for user ...

From
Adrian Klaver
Date:
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.klaver@aklaver.com


Re: php password authentication failed for user ...

From
basti
Date:
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
>>
>>
>
>


Re: php password authentication failed for user ...

From
rob stone
Date:


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@unix-solution.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



Re: php password authentication failed for user ...

From
Adrian Klaver
Date:
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.klaver@aklaver.com


Re: php password authentication failed for user ...

From
Adrian Klaver
Date:
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.klaver@aklaver.com


Re: php password authentication failed for user ...

From
basti
Date:
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.


Re: php password authentication failed for user ...

From
Alban Hertroys
Date:
On 9 July 2014 15:10, basti <mailinglist@unix-solution.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.


Re: php password authentication failed for user ...

From
Scott Marlowe
Date:
On Wed, Jul 9, 2014 at 5:04 AM, basti <mailinglist@unix-solution.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.


Re: php password authentication failed for user ...

From
basti
Date:
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@unix-solution.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.
>>
>
>


Re: php password authentication failed for user ...

From
Scott Marlowe
Date:
On Wed, Jul 9, 2014 at 6:37 AM, basti <basti@unix-solution.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


Re: php password authentication failed for user ...

From
Francisco Olarte
Date:
Hi:

On Wed, Jul 9, 2014 at 2:37 PM, basti <basti@unix-solution.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.


Re: php password authentication failed for user ...

From
Ken Tanzer
Date:
On Wed, Jul 9, 2014 at 5:37 AM, basti <basti@unix-solution.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
(253) 245-3801

learn more about AGENCY or
follow the discussion.

Re: php password authentication failed for user ...

From
basti
Date:
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@unix-solution.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
>
>


Re: php password authentication failed for user ...

From
Adrian Klaver
Date:
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@unix-solution.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.klaver@aklaver.com


Re: php password authentication failed for user ...

From
basti
Date:
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@unix-solution.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
>>>
>>>
>>
>>
>
>


Re: php password authentication failed for user ...

From
Adrian Klaver
Date:
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.klaver@aklaver.com


Re: php password authentication failed for user ...

From
basti
Date:
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
>>
>
>




Re: php password authentication failed for user ...

From
Adrian Klaver
Date:
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.klaver@aklaver.com


Re: php password authentication failed for user ...

From
"Daniel Verite"
Date:
    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


Re: php password authentication failed for user ...

From
Adrian Klaver
Date:
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.klaver@aklaver.com


Re: php password authentication failed for user ...

From
basti
Date:
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
>>
>
>


Re: php password authentication failed for user ...

From
Marc Mamin
Date:

> -----Original Message-----
> From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-
> owner@postgresql.org] On Behalf Of basti
> Sent: Mittwoch, 16. Juli 2014 10:14
> To: pgsql-general@postgresql.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@postgresql.org) To make
> changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general

Re: php password authentication failed for user ...

From
Adrian Klaver
Date:
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.klaver@aklaver.com


Re: php password authentication failed for user ...

From
basti
Date:
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
>>
>
>