Thread: On Ubuntu 12.04 i do have two psql one of those isn't working

On Ubuntu 12.04 i do have two psql one of those isn't working

From
Yvon Thoraval
Date:

I'm testing my second PostgreSQL install on Xunutu 12.04 after a disk crash.

Everything went well using command line where i was able, after config and setup, to log into a db using :
$ psql <IPV4 or IPV6 of the server> -U yt -d yt_tests

Then i wanted to test postgres thru php where i got Http error 500.

After that i discovered that i do have TWO psql installed :

the first :
lrwxrwxrwx 1 root root 37 mars   6  2012 /usr/bin/psql -> ../share/postgresql-common/pg_wrapper 

the second :
-rwxr-xr-x 1 root root 433224 août  17 00:58 /usr/lib/postgresql/9.1/bin/psql


the first is working not the second :

yt@D620 $ sudo -s -u postgres
[sudo] password for yt:
zsh: locking failed for /home/yt/.zsh_history: permission non accordée: reading anyway

using the first one :
postgres@D620 $ /usr/bin/psql
psql (9.1.5)
Type "help" for help.

postgres=# \q


using the second :
postgres@D620 $ /usr/lib/postgresql/9.1/bin/psql
psql: server closed the connection unexpectedly
    This probably means the server terminated abnormally
    before or while processing the request.
could not send startup packet: Relais brisé (pipe)
zsh: exit 2     /usr/lib/postgresql/9.1/bin/psql


then, i wonder how to workaround this "installation bugg" because i suspect php is using the second not working psql where the first is the one being in my PATH.
--
Yvon


Re: On Ubuntu 12.04 i do have two psql one of those isn't working

From
Raymond O'Donnell
Date:
On 17/09/2012 07:15, Yvon Thoraval wrote:
>
> I'm testing my second PostgreSQL install on Xunutu 12.04 after a disk crash.
>
> Everything went well using command line where i was able, after config
> and setup, to log into a db using :
> $ psql <IPV4 or IPV6 of the server> -U yt -d yt_tests
>
> Then i wanted to test postgres thru php where i got Http error 500.
>
> After that i discovered that i do have TWO psql installed :
>
> the first :
> lrwxrwxrwx 1 root root 37 mars   6  2012 /usr/bin/psql ->
> ../share/postgresql-common/pg_wrapper
>
> the second :
> -rwxr-xr-x 1 root root 433224 août  17 00:58
> /usr/lib/postgresql/9.1/bin/psql

The first isn't a "real" psql - it's a symlink to pg_wrapper, which is
how Debian and Ubuntu allow you to run different Postgres versions and
clusters on the same machine. You call the client program (psql,
pg_dump, etc) you want as usual, but pass it the --cluster option, as
follows:

  psql --cluster 9.1/main (....)

and then pg_wrapper calls the correct version of the client program.


>
> then, i wonder how to workaround this "installation bugg" because i
> suspect php is using the second not working psql where the first is the
> one being in my PATH.

PHP doesn't use psql, it uses libpq (the client library).

Ray.

--
Raymond O'Donnell :: Galway :: Ireland
rod@iol.ie


Re: On Ubuntu 12.04 i do have two psql one of those isn't working

From
Yvon Thoraval
Date:


2012/9/17 Raymond O'Donnell <rod@iol.ie>

The first isn't a "real" psql - it's a symlink to pg_wrapper, which is
how Debian and Ubuntu allow you to run different Postgres versions and
clusters on the same machine. You call the client program (psql,
pg_dump, etc) you want as usual, but pass it the --cluster option, as
follows:

  psql --cluster 9.1/main (....)

and then pg_wrapper calls the correct version of the client program.


OK, thanks very much, I'll try that ASAP.
 
>
> then, i wonder how to workaround this "installation bugg" because i
> suspect php is using the second not working psql where the first is the
> one being in my PATH.

PHP doesn't use psql, it uses libpq (the client library).

then, the php link to the client library is faulty.

I've to find why.
surprisingly, when from a php script i want to connect to another pgsql server, on another machine, by it's IPV6 addresse it works as expected...


--
Yvon


Re: On Ubuntu 12.04 i do have two psql one of those isn't working

From
Raymond O'Donnell
Date:
On 17/09/2012 12:52, Yvon Thoraval wrote:

>
> then, the php link to the client library is faulty.

What makes you think this? Can you show the output from a PHP script
(not psql)? - something simple like...

$conn = pg_connect(....);
$rs = pg_query(....);

...just to establish whether the connection works.

> I've to find why.
> surprisingly, when from a php script i want to connect to another pgsql
> server, on another machine, by it's IPV6 addresse it works as expected...

Maybe you have Postgres set up to listen only over IPV6? However,
without seeing the actual error messages from PHP, I'm only guessing.

Ray.

--
Raymond O'Donnell :: Galway :: Ireland
rod@iol.ie


Re: On Ubuntu 12.04 i do have two psql one of those isn't working

From
Yvon Thoraval
Date:
I've found the prob.
In my postgresql.conf file the default port is setup to 5433 instead of 5432 as previously...

sorry for the noise.

Re: On Ubuntu 12.04 i do have two psql one of those isn't working

From
Raymond O'Donnell
Date:
On 18/09/2012 16:10, Yvon Thoraval wrote:
> I've found the prob.
> In my postgresql.conf file the default port is setup to 5433 instead of
> 5432 as previously...

OK - you probably had two versions of PG installed at some point - when
you install a second version of PG alongside an existing one on Debian &
Ubuntu, it automatically puts it on 5433.

Ray.


--
Raymond O'Donnell :: Galway :: Ireland
rod@iol.ie


Re: On Ubuntu 12.04 i do have two psql one of those isn't working

From
Yvon Thoraval
Date:


2012/9/18 Raymond O'Donnell <rod@iol.ie>
On 18/09/2012 16:10, Yvon Thoraval wrote:
> I've found the prob.
> In my postgresql.conf file the default port is setup to 5433 instead of
> 5432 as previously...

OK - you probably had two versions of PG installed at some point - when
you install a second version of PG alongside an existing one on Debian &
Ubuntu, it automatically puts it on 5433.


Thanks, fine, U're right because when I attempted to change the port number to 5432 in my postgresql.conf, when restarting the server i got that message :
$  sudo /etc/init.d/postgresql restart
[sudo] password for yt: 
 * Restarting PostgreSQL 9.1 database server                                                                                                                   * Error: Port conflict: another instance is already running on /var/run/postgresql with port 5432

Quite frankly i don't know where this first postgresl come from...
That make me loose a lot of time for "nothing"...



--
Yvon


Re: On Ubuntu 12.04 i do have two psql one of those isn't working

From
Jasen Betts
Date:
On 2012-09-18, Raymond O'Donnell <rod@iol.ie> wrote:
> On 18/09/2012 16:10, Yvon Thoraval wrote:
>> I've found the prob.
>> In my postgresql.conf file the default port is setup to 5433 instead of
>> 5432 as previously...
>
> OK - you probably had two versions of PG installed at some point - when
> you install a second version of PG alongside an existing one on Debian &
> Ubuntu, it automatically puts it on 5433.

Debian's pg_upgradecluster will leave you with the new cluster running
on 5433. (it's not pg_upgrade, it's some sort of script)


⚂⚃ 100% natural