Thread: Re: [PHP] Accessing Postgres db from apache using PHP

Re: [PHP] Accessing Postgres db from apache using PHP

From
"bruce"
Date:
ok....

i'm still somewhat confused... this is probably a pg_hba.conf issue.....

my pg_hba.conf looks like:
# TYPE     DATABASE    IP_ADDRESS    MASK               AUTH_TYPE
AUTH_ARGUMENT

#local      all                                          trust
#host       all         127.0.0.1     255.255.255.255    trust

# Using sockets credentials for improved security. Not available everywhere,
# but works on Linux, *BSD (and probably some others)

#local  all ident   sameuser
#local   all                                             trust
#host   all             127.0.0.1       255.255.255.255 trust
#host   template1       127.0.0.1       255.255.255.255 trust
host    gforge  127.0.0.1       255.255.255.255 trust

i've logged into the server as gforge, and tried to do the psql command
    -> psql -h localhost gforge

psql: FATAL 1:  No pg_hba.conf entry for host 127.0.0.1, user gforge,
database gforge

i've also made sure the php.ini file is correct....
i can do a psql, and then a "\l" to see the gforge database

i've tried a number different settings in the pg_hba.conf file... with no
luck...

i'm willing to bet it's something pretty simple... but i can't see it..
searchs of google haven't shed any light!!!

a bottle of your favorite drink to whoever can help!!!!


thanks....

bruce
bedouglas@earthlink.net

ps...i'd even let someone remotely log in if it would help!!!


-----Original Message-----
From: pgsql-php-owner@postgresql.org
[mailto:pgsql-php-owner@postgresql.org]On Behalf Of Rod Taylor
Sent: Sunday, July 27, 2003 7:24 PM
To: bedouglas@earthlink.net
Cc: pgsql-novice@postgresql.org; pgsql-php@postgresql.org
Subject: Re: [PHP] Accessing Postgres db from apache using PHP


> i then do a:
>     $tmp = "host=localhost dbname=gforge user=gforge password=gforge";
>     $conn = @pg_connect($tmp);

Since host=localhost, the client will attempt to connect to the server
on 127.0.0.1.  By default, TCPIP access is not enabled.  To do so, see
postgresql.conf, make the change to the tcpip variable, and HUP the
server.

However, if you leave host=<blank>, the client will attempt to connect
to the server via the local domain socket which is both enabled by
default and should be a touch faster due to more efficient data
transmission.


Re: [PHP] Accessing Postgres db from apache using PHP

From
Rod Taylor
Date:
> my pg_hba.conf looks like:
> # TYPE     DATABASE    IP_ADDRESS    MASK               AUTH_TYPE
> AUTH_ARGUMENT
>
> #local      all                                          trust
> #host       all         127.0.0.1     255.255.255.255    trust
>
> # Using sockets credentials for improved security. Not available everywhere,
> # but works on Linux, *BSD (and probably some others)
>
> #local  all ident   sameuser
> #local   all                                             trust
> #host   all             127.0.0.1       255.255.255.255 trust
> #host   template1       127.0.0.1       255.255.255.255 trust
> host    gforge  127.0.0.1       255.255.255.255 trust
>
> i've logged into the server as gforge, and tried to do the psql command
>     -> psql -h localhost gforge
>
> psql: FATAL 1:  No pg_hba.conf entry for host 127.0.0.1, user gforge,
> database gforge

Your using a 7.2.x database or 7.3.x?

The file segments you have shown look like the 7.2.x format but the
error message looks like something you would get out of a 7.3.x database
(7.3.x added a user portion).

If 7.3.x, try:

# TYPE DATABASE USER    IP-ADDRESS IP-MASK         METHOD
host   gforge   gforge  127.0.0.1  255.255.255.255 trust


If 7.2.x, did you HUP or restart the server after making changes to the
file?

Attachment