From: "Lim Berger" <[EMAIL PROTECTED]>
To: "John Coulthard" <[EMAIL PROTECTED]>
CC: pgsql-general@postgresql.org
Subject: Re: [GENERAL] Unable to connect to PostgreSQL server via PHP
Date: Mon, 13 Aug 2007 18:51:37 +0800

On 8/13/07, John Coulthard <[EMAIL PROTECTED]> wrote:
> The part of the php code for the connection is
>
>
> $dbconn=pg_connect( "dbname=lumbribase host=localhost port=5432
> user=postgres password=$PG_PASS" );
> if ( ! $dbconn ) {
>     echo "Error connecting to the database !<br> " ;
>     printf("%s", pg_errormessage( $dbconn ) );
>     exit(); }
>
> This code works on zeldia
> http://zeldia.cap.ed.ac.uk/Lumbribase/search_id.php
> but not on xyala http://xyala.cap.ed.ac.uk/Lumbribase/search_id.php
>
> So it's something to do with the way xyala is set up. I'm sure I'm missing
> something obvious but what..?
>
> It's not  a firewall issue because it persists when the iptabes are off.
>
> What does "could not connect to server: Permission denied" mean?  Have I
> done some something as root or me that I should have done as
> user postgres?



Hi John,

Had the same issue. Try the following steps:

1. PGHBA.CONF

This is an important file. Mine (on Linux CentOS 4) is located at
"/var/lib/pgsql/data/pghba.conf". Make sure it looks like the
following.

local   all         all                                              md5
host    all         all         127.0.0.1          255.255.255.255   md5


2. POSTGRESQL.CONF


listen_addresses = 'localhost,*'
#port = 5432
....other settings....


3. PHP CODE


link = pg_connect("host=localhost dbname=MYDB user=MYUSER password=MYPASS");

--
That is all you need. Don't specify anything else in the connection
string. Let me know how it goes.

LB

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend


Thanks for the sugestions but they don''t solve the problem. I do notice that if I set listen_addresses='localhost,*' then I get the following when I start postgres...

bash-3.00$ ps -ef | grep postgres
root      9669  8757  0 13:34 pts/5    00:00:00 su postgres
postgres  9670  9669  0 13:34 pts/5    00:00:00 bash
postgres  9673  9670  0 13:34 pts/5    00:00:00 ps -ef
postgres  9674  9670  0 13:34 pts/5    00:00:00 grep postgres
bash-3.00$ /usr/bin/pg_ctl -D /var/lib/pgsql/data start
postmaster starting
bash-3.00$ LOG:  could not bind IPv4 socket: Address already in use
HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.

bash-3.00$

it does start though. But if I just have localhost or * as the listen_addresses it starts without error.

That's not my problem though this is "could not connect to server: Permission denied" If it's denying permission I must have the permissions set wrong but where to I start looking for them? All sub dirs in /var/lib/pgsql are owned by postgres and seem to have the same permissions on both systems.

Cheers

_________________________________________________________________
Find a local pizza place, movie theater, and moreĀ….then map the best route! http://maps.live.com/default.aspx?v=2&ss=yp.bars~yp.pizza~yp.movie%20theater&cp=42.358996~-71.056691&style=r&lvl=13&tilt=-90&dir=0&alt=-1000&scene=950607&encType=1&FORM=MGAC01


---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Reply via email to