php password authentication failed for user ...

Started by bastialmost 12 years ago29 messagesgeneral
Jump to latest
#1basti
mailinglist@unix-solution.de

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

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#2Bill Moran
wmoran@potentialtech.com
In reply to: basti (#1)
Re: php password authentication failed for user ...

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>

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#3Francisco Olarte
folarte@peoplecall.com
In reply to: basti (#1)
Re: php password authentication failed for user ...

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.

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#4basti
mailinglist@unix-solution.de
In reply to: Bill Moran (#2)
Re: php password authentication failed for user ...

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?

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#5basti
mailinglist@unix-solution.de
In reply to: Francisco Olarte (#3)
Re: php password authentication failed for user ...

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.

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#6basti
basti@unix-solution.de
In reply to: basti (#5)
Re: php password authentication failed for user ...

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.

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#7Adrian Klaver
adrian.klaver@aklaver.com
In reply to: basti (#1)
Re: php password authentication failed for user ...

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

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#8basti
mailinglist@unix-solution.de
In reply to: Adrian Klaver (#7)
Re: php password authentication failed for user ...

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

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#9rob stone
floriparob@gmail.com
In reply to: basti (#4)
Re: php password authentication failed for user ...

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

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#10Adrian Klaver
adrian.klaver@aklaver.com
In reply to: basti (#8)
Re: php password authentication failed for user ...

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

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#11Adrian Klaver
adrian.klaver@aklaver.com
In reply to: rob stone (#9)
Re: php password authentication failed for user ...

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

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#12basti
mailinglist@unix-solution.de
In reply to: rob stone (#9)
Re: php password authentication failed for user ...

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.

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#13Alban Hertroys
haramrae@gmail.com
In reply to: basti (#8)
Re: php password authentication failed for user ...

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.

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#14Scott Marlowe
scott.marlowe@gmail.com
In reply to: basti (#1)
Re: php password authentication failed for user ...

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.

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#15Scott Marlowe
scott.marlowe@gmail.com
In reply to: basti (#6)
Re: php password authentication failed for user ...

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

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#16Francisco Olarte
folarte@peoplecall.com
In reply to: basti (#6)
Re: php password authentication failed for user ...

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.

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#17Ken Tanzer
ken.tanzer@gmail.com
In reply to: basti (#6)
Re: php password authentication failed for user ...

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
*http://agency-software.org/ <http://agency-software.org/&gt;*
*https://agency-software.org/demo/client
<https://agency-software.org/demo/client&gt;*
ken.tanzer@agency-software.org
(253) 245-3801

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

#18basti
mailinglist@unix-solution.de
In reply to: Scott Marlowe (#15)
Re: php password authentication failed for user ...

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

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#19Adrian Klaver
adrian.klaver@aklaver.com
In reply to: basti (#18)
Re: php password authentication failed for user ...

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

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#20basti
mailinglist@unix-solution.de
In reply to: Adrian Klaver (#19)
Re: php password authentication failed for user ...

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

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#21Adrian Klaver
adrian.klaver@aklaver.com
In reply to: basti (#20)
#22basti
basti@unix-solution.de
In reply to: Adrian Klaver (#21)
#23basti
mailinglist@unix-solution.de
In reply to: basti (#22)
#24Adrian Klaver
adrian.klaver@aklaver.com
In reply to: basti (#20)
#25Daniel Verite
daniel@manitou-mail.org
In reply to: basti (#18)
#26Adrian Klaver
adrian.klaver@aklaver.com
In reply to: basti (#23)
#27basti
mailinglist@unix-solution.de
In reply to: Adrian Klaver (#24)
#28Marc Mamin
M.Mamin@intershop.de
In reply to: basti (#27)
#29Adrian Klaver
adrian.klaver@aklaver.com
In reply to: basti (#27)