Обсуждение: trouble with connection

Поиск
Список
Период
Сортировка

trouble with connection

От
Didier Gasser-Morlay
Дата:
Hello,

I am confused with the users configuration:

I have created a user called webstar; granted it all on one database
(called webstar).
I want the user webstar to provide a password

so I have the following pg_hba.conf


# "local" is for Unix domain socket connections only
local   all         webstar                            md5
local   all         all                                ident sameuser
# IPv4 local connections:
host    all         all         127.0.0.1/32           ident sameuser
# IPv6 local connections:
host    all         all         ::1/128                ident sameuser

this work fine from the command line where i can use pgsql with

pgsql -U webstar -W

I am prompted for a password and I can connect.

Now when I try to connect from php I get

pg_connect(): Unable to connect to PostgreSQL server: FATAL: Ident
authentication failed for user "webstar"

it clearly says that the user webstar is trying for an ident
connection, not a password one. and I do not understand why.

can you enlighten me ?

thanks in advance

Didier

Re: trouble with connection

От
Andreas Wenk
Дата:
Didier Gasser-Morlay schrieb:
> Hello,
>
> I am confused with the users configuration:
>
> I have created a user called webstar; granted it all on one database
> (called webstar).
> I want the user webstar to provide a password
>
> so I have the following pg_hba.conf
>
>
> # "local" is for Unix domain socket connections only
> local   all         webstar                            md5
> local   all         all                                ident sameuser
> # IPv4 local connections:
> host    all         all         127.0.0.1/32           ident sameuser
> # IPv6 local connections:
> host    all         all         ::1/128                ident sameuser
>
> this work fine from the command line where i can use pgsql with
>
> pgsql -U webstar -W
>
> I am prompted for a password and I can connect.
>
> Now when I try to connect from php I get
>
> pg_connect(): Unable to connect to PostgreSQL server: FATAL: Ident
> authentication failed for user "webstar"
>
> it clearly says that the user webstar is trying for an ident
> connection, not a password one. and I do not understand why.
>
> can you enlighten me ?
>
> thanks in advance
>
> Didier

I assume you're not running 8.4, because sameuser is deprecated. So ident sameuser means,
that you have a systemuser called webstar. Does this user exist? If not, add the user with

adduser webstar

and provide a password. Then it should work.

Cheers

Andy


Re: trouble with connection

От
Didier Gasser-Morlay
Дата:
2009/7/29 Andreas Wenk <a.wenk@netzmeister-st-pauli.de>:
> Didier Gasser-Morlay schrieb:
>>
>> Hello,
>>
>> I am confused with the users configuration:
>>
>> I have created a user called webstar; granted it all on one database
>> (called webstar).
>> I want the user webstar to provide a password
>>
>> so I have the following pg_hba.conf
>>
>>
>> # "local" is for Unix domain socket connections only
>> local   all         webstar                            md5
>> local   all         all                                ident sameuser
>> # IPv4 local connections:
>> host    all         all         127.0.0.1/32           ident sameuser
>> # IPv6 local connections:
>> host    all         all         ::1/128                ident sameuser
>>
>> this work fine from the command line where i can use pgsql with
>>
>> pgsql -U webstar -W
>>
>> I am prompted for a password and I can connect.
>>
>> Now when I try to connect from php I get
>>
>> pg_connect(): Unable to connect to PostgreSQL server: FATAL: Ident
>> authentication failed for user "webstar"
>>
>> it clearly says that the user webstar is trying for an ident
>> connection, not a password one. and I do not understand why.
>>
>> can you enlighten me ?
>>
>> thanks in advance
>>
>> Didier
>
> I assume you're not running 8.4, because sameuser is deprecated. So ident
> sameuser means, that you have a systemuser called webstar. Does this user
> exist? If not, add the user with
>
> adduser webstar
>
> and provide a password. Then it should work.
>
> Cheers
>
> Andy
>
>

Andreas,

thanks a lot for your speedy answer. you are right, the system uses 8.3.7.

Where I am confused it that I created in pg_hba.conf an entry
specifically for  the user webstar

 local   all         webstar                            md5

and placed it before

 local   all         all                                ident sameuser

This works from the command line to use psql. so, to me it seems to
say that this works.

It is only when connecting from php (using pg_connect) that it fails badly.

I also tried as you suggested to 'adduser webstar' and I got the same

Didier

Re: trouble with connection

От
"A. Kretschmer"
Дата:
In response to Didier Gasser-Morlay :
> Where I am confused it that I created in pg_hba.conf an entry
> specifically for  the user webstar
>
>  local   all         webstar                            md5
>
> and placed it before
>
>  local   all         all                                ident sameuser
>
> This works from the command line to use psql. so, to me it seems to
> say that this works.
>
> It is only when connecting from php (using pg_connect) that it fails badly.

PHP don't use the local-Method (socket), it connects via tcp/ip. So you
need a host-entry:

host  all  all       x.y.z.y/mask   md5

Replace the x.y.z.y/mask with your CIDR.


Andreas
--
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net

Re: trouble with connection

От
Andreas Wenk
Дата:
A. Kretschmer schrieb:
> PHP don't use the local-Method (socket), it connects via tcp/ip. So you
> need a host-entry:
>
> host  all  all       x.y.z.y/mask   md5
>
> Replace the x.y.z.y/mask with your CIDR.
>
>
> Andreas

my oversight ;-) Thanks Andreas ...

Cheers

Andy