Re: php password authentication failed for user ...

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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Steven Winfield 2014-07-15 14:16:24 Last reclustering time
Previous Message David G Johnston 2014-07-15 13:46:05 Re: Design ? table vs. view?