Обсуждение: PostgreSQL from a newcomers perspective
New to PostgreSQL.. not to databases.. or Linux in general.. Let's asume I got convinced by your advocacy and decided to install and play a bit with PostgreSQL to discover it's features and how I can use them. Installation went fine. I decided to read the long version.. at some point I was told to create a user postgres. I didn't find recommended settings for this user like if it needs a shell and where the users homedir is supposed to be.. I mean.. I can understand that PostgreSQL would require something simular to MySQL.. if it does.. then I would expect it to be in the docs->installation->long version. Here I find myself behind a Linux box that can't connect via PHP.. solved that one too.. Found the solution quicker on PHP.net then on postgresql.org.. even searched for postmaster -i (and other keywords I could think of) on postgresql.org.. no results.. FWIW.. seaching for the keyword postmaster did turn up the app_postmaster page.. Long story short, in order to get things going a newcomer needs to search a lot (preferrable Google) and doesn't find all the information in the getting started section... or at the first place he/she looks: the docs found at postgresql.org.. I'm quite sure the information is there but the way to it is not always logical.... IMHO :-) I'm not assuming to be spoon fed but a more clear/accessible manual would certainly help.. Would be nice if there was a table showing the commands used in MySQL (mysql) and the commands with the same result used in PostgreSQL (psql).. Just my EUR 0,02 B.
B. van Ouwerkerk writes: > Installation went fine. I decided to read the long version.. at some point > I was told to create a user postgres. > I didn't find recommended settings for this user like if it needs a shell > and where the users homedir is supposed to be.. I mean.. I can understand > that PostgreSQL would require something simular to MySQL.. if it does.. > then I would expect it to be in the docs->installation->long version. Agreed, that could be added. > Here I find myself behind a Linux box that can't connect via PHP.. solved > that one too.. Found the solution quicker on PHP.net then on > postgresql.org.. even searched for postmaster -i (and other keywords I > could think of) on postgresql.org.. no results.. FWIW.. seaching for the > keyword postmaster did turn up the app_postmaster page.. Would you care to tell us what you had to do? Because using the standard installation I can connect via PHP just fine. -- Peter Eisentraut peter_e@gmx.net
> > Here I find myself behind a Linux box that can't connect via PHP.. solved > > that one too.. Found the solution quicker on PHP.net then on > > postgresql.org.. even searched for postmaster -i (and other keywords I > > could think of) on postgresql.org.. no results.. FWIW.. seaching for the > > keyword postmaster did turn up the app_postmaster page.. > >Would you care to tell us what you had to do? Because using the standard >installation I can connect via PHP just fine. I couldn't without modifying either postgresql.conf or start PostgreSQL with --i Obvious if you know it.. but not if you're new.. B.
B. van Ouwerkerk writes: > >Would you care to tell us what you had to do? Because using the standard > >installation I can connect via PHP just fine. > > I couldn't without modifying either postgresql.conf or start PostgreSQL > with --i There must be something wrong. PHP should be able to connect via Unix-domain sockets. -- Peter Eisentraut peter_e@gmx.net
>> > Here I find myself behind a Linux box that can't connect via PHP.. solved >> > that one too.. Found the solution quicker on PHP.net then on >> > postgresql.org.. even searched for postmaster -i (and other keywords I >> > could think of) on postgresql.org.. no results.. FWIW.. seaching for the >> > keyword postmaster did turn up the app_postmaster page.. >> >>Would you care to tell us what you had to do? Because using the standard >>installation I can connect via PHP just fine. > >I couldn't without modifying either postgresql.conf or start PostgreSQL >with --i Only one - This was on a default install as per instructions found on the postgresql.org website. Started as per the same instructions: http://www.postgresql.org/docs/current/static/installation.html B.
> > I couldn't without modifying either postgresql.conf or start PostgreSQL
> > with --i
>
>There must be something wrong. PHP should be able to connect via
>Unix-domain sockets.
I'll be the first to admit that I might have made a mistake. This is on a
box I use for testing only.. so nothing bad will happen if I muck things up..
This is the error I got in my errorlog:
Unable to connect to PostgreSQL server: could not connect to server:
Connection refused
Is the server running locally and accepting
connections on Unix domain socket "/tmp/5432"?
in /path_to/filename.php on line 61
From a little search on Google it seems a pretty common problem.. So if I
made a mistake I'm probably not the first :-)
B.
On Mon, 2003-12-01 at 17:50, B. van Ouwerkerk wrote: > This is the error I got in my errorlog: > Unable to connect to PostgreSQL server: could not connect to server: > Connection refused > Is the server running locally and accepting > connections on Unix domain socket "/tmp/5432"? > in /path_to/filename.php on line 61 That socket path is wrong. It should be /tmp/.s.PGSQL.5432. How is PHP getting it? -- Oliver Elphick Oliver.Elphick@lfix.co.uk Isle of Wight, UK http://www.lfix.co.uk/oliver GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C ======================================== "Who is like unto thee, O LORD, among the gods? who is like thee, glorious in holiness, fearful in praises, doing wonders?" Exodus 15:11
The problem here is really on the PHP side, because the docs of PHP don't
tell you how to create a connect string that works for local Postgres
installs (well, the docs exist, but they are hard to find).
For PEAR, it's
$db = DB::connect('pgsql://USERNAME@unix(/tmp)/DBNAME');
Jon
On Mon, 1 Dec 2003, Peter Eisentraut wrote:
> B. van Ouwerkerk writes:
>
> > Installation went fine. I decided to read the long version.. at some point
> > I was told to create a user postgres.
> > I didn't find recommended settings for this user like if it needs a shell
> > and where the users homedir is supposed to be.. I mean.. I can understand
> > that PostgreSQL would require something simular to MySQL.. if it does..
> > then I would expect it to be in the docs->installation->long version.
>
> Agreed, that could be added.
>
> > Here I find myself behind a Linux box that can't connect via PHP.. solved
> > that one too.. Found the solution quicker on PHP.net then on
> > postgresql.org.. even searched for postmaster -i (and other keywords I
> > could think of) on postgresql.org.. no results.. FWIW.. seaching for the
> > keyword postmaster did turn up the app_postmaster page..
>
> Would you care to tell us what you had to do? Because using the standard
> installation I can connect via PHP just fine.
>
> --
> Peter Eisentraut peter_e@gmx.net
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
>
> > Is the server running locally and accepting > > connections on Unix domain socket "/tmp/5432"? > > in /path_to/filename.php on line 61 > >That socket path is wrong. It should be /tmp/.s.PGSQL.5432. How is PHP >getting it? No idea. The socket path seems to be correct.. at least.. it looks to me like PHP is looking at the right place.. As soon as I start PG with the -i option PHP connects just fine.. just like when I modify postgresql.conf.. When I run with the -i option I'm getting something listening at port 5432 but it doesn't appear when running without -i.. tested it with netstat.. I was testing with an app of which I know it supports PG.. Will see if how it flies if I throw some code together myself. This will be interesting.. B.
In this case I found the problem to originate from the application, it uses
tcp/ip to connect..
Right now I can connect without any problem by using:
$dbconn = pg_connect("dbname=name_of_database user=user_name
password=just_a_password");
Great!!! I can't wait until I get my hands on a few good books..
B.
At 10:59 01-12-2003 -0800, Jonathan Bartlett wrote:
>The problem here is really on the PHP side, because the docs of PHP don't
>tell you how to create a connect string that works for local Postgres
>installs (well, the docs exist, but they are hard to find).
>
>For PEAR, it's
>
>$db = DB::connect('pgsql://USERNAME@unix(/tmp)/DBNAME');
>
>Jon
>
>On Mon, 1 Dec 2003, Peter Eisentraut wrote:
>
> > B. van Ouwerkerk writes:
> >
> > > Installation went fine. I decided to read the long version.. at some
> point
> > > I was told to create a user postgres.
> > > I didn't find recommended settings for this user like if it needs a shell
> > > and where the users homedir is supposed to be.. I mean.. I can understand
> > > that PostgreSQL would require something simular to MySQL.. if it does..
> > > then I would expect it to be in the docs->installation->long version.
> >
> > Agreed, that could be added.
> >
> > > Here I find myself behind a Linux box that can't connect via PHP.. solved
> > > that one too.. Found the solution quicker on PHP.net then on
> > > postgresql.org.. even searched for postmaster -i (and other keywords I
> > > could think of) on postgresql.org.. no results.. FWIW.. seaching for the
> > > keyword postmaster did turn up the app_postmaster page..
El Lun 01 Dic 2003 13:21, Peter Eisentraut escribió:
> B. van Ouwerkerk writes:
> > >Would you care to tell us what you had to do? Because using the
> > > standard installation I can connect via PHP just fine.
> >
> > I couldn't without modifying either postgresql.conf or start PostgreSQL
> > with --i
>
> There must be something wrong. PHP should be able to connect via
> Unix-domain sockets.
It does, but I guess only when you don't specify a host.
pg_connect("dbname=DB");
If you specify a host it will use TCP connections.
--
El mejor sistema operativo es aquel que te da de comer.
Cuida tu dieta.
-----------------------------------------------------------------
Martin Marques | mmarques@unl.edu.ar
Programador, Administrador | Centro de Telematica
Universidad Nacional
del Litoral
-----------------------------------------------------------------
----- Original Message ----- From: "B. van Ouwerkerk" <bvo@atz.nl> > >I couldn't without modifying either postgresql.conf or start PostgreSQL > >with --i > > Only one - > Technically speaking this is as much a PHP coding issue as it is a PostgreSQL issue. If the PHP connection string has a host field in it, libpq will try to connect via a tcp/ip rather than local socket. PHP can still connect locally if the socket is specified properly (see PHP manual for information). I would, however, suggest that this is not expected behavior from a beginner standpoint, and it would be useful to add a paragraph to the documentation in the post-install setup section concerning the setting tcpip_sockets in the postgresql.conf file. I have seen this one baffle others too, Best Wishes, Chris Travers