Thread: Connexion to Postgresql using TCP/IP
Hello !
I use a PostgreSQL server 7.4 on Linux Mandrake 10 with IP 192.168.0.15,
a database gestix is created.
An PostegreSQL user "postgres" id defined on this server,I add in the .bash_profile of this user the line :
PGDATA=$HOME/data; export PGDATA
My PC have IP 192.168.0.10.
in postgresql.conf I have :
tcpip_socket = true
in pg_hba.conf I add :
host all all 192.168.0.10 255.255.255.255 trust
(I know, I shoul'd use better identification, it's for testing)
When I log as postgres if I use :
pg_ctl start
the postmaster is coming up,
I can connect from the PC with PgAdmin3 under Windows XP.
On automatic startup, or when I use :
service postgresql start
I can't connect from the PC. I get the message :
FATAL : no pg_hba.conf entry for host "192.168.0.10", user "postgres", database "gestix", SSL off
I don't understand my error (probably I made one ?)
I'm becoming mad !
What's the matter ?
Best regards.
Luc ROLLAND
=?iso-8859-1?Q?Secr=E9tariat?= <ets@rolland-fr.com> writes: > I use a PostgreSQL server 7.4 on Linux Mandrake 10 with IP 192.168.0.15, > a database gestix is created. > An PostegreSQL user "postgres" id defined on this server, > I add in the .bash_profile of this user the line : > PGDATA=$HOME/data; export PGDATA > When I log as postgres if I use : > pg_ctl start > the postmaster is coming up, > I can connect from the PC with PgAdmin3 under Windows XP. > On automatic startup, or when I use : > service postgresql start > I can't connect from the PC. It sounds like the service-start case is picking a different data directory than you're expecting --- likely /var/lib/postgres, or whatever the installation default is. I'm not sure what's in Mandrake 10, but I can tell you that in the Red Hat RPMs, putting a PGDATA definition into ~/.bash_profile did not work until very very recently. The init script did su - postgres -s /bin/sh -c "postmaster ..." thus forcing /bin/sh to be used, and /bin/sh won't pay any attention to ~/.bash_profile. This is fixed in recent RPMs (basically by removing "-s /bin/sh"), or you can dodge the problem by copying the variable definitions into regular sh's ~/.profile. regards, tom lane
----- Original Message ----- From: "Tom Lane" <tgl@sss.pgh.pa.us> To: "Secrétariat" <ets@rolland-fr.com> Cc: <pgsql-general@postgresql.org> Sent: Friday, July 23, 2004 4:33 PM Subject: Re: [GENERAL] Connexion to Postgresql using TCP/IP > =?iso-8859-1?Q?Secr=E9tariat?= <ets@rolland-fr.com> writes: > > I use a PostgreSQL server 7.4 on Linux Mandrake 10 with IP 192.168.0.15, > > a database gestix is created. > > An PostegreSQL user "postgres" id defined on this server, > > I add in the .bash_profile of this user the line : > > PGDATA=$HOME/data; export PGDATA > > > When I log as postgres if I use : > > pg_ctl start > > the postmaster is coming up, > > I can connect from the PC with PgAdmin3 under Windows XP. > > > On automatic startup, or when I use : > > service postgresql start > > I can't connect from the PC. > > It sounds like the service-start case is picking a different data > directory than you're expecting --- likely /var/lib/postgres, or > whatever the installation default is. > > I'm not sure what's in Mandrake 10, but I can tell you that in the Red > Hat RPMs, putting a PGDATA definition into ~/.bash_profile did not work > until very very recently. The init script did > su - postgres -s /bin/sh -c "postmaster ..." > thus forcing /bin/sh to be used, and /bin/sh won't pay any attention > to ~/.bash_profile. > > This is fixed in recent RPMs (basically by removing "-s /bin/sh"), or > you can dodge the problem by copying the variable definitions into > regular sh's ~/.profile. > > regards, tom lane > You are perfectly right ! I edit /etc/rc.d/init.d/postgresql, and I replace the values for PGDATA with the path to my database. Now I can connect the PC when I use : service postgresql start It was due to an update from PG 7.3 to PG 7.4 who has modified the init script postgresql ! Is it possible to avaid this problem by using the : /etc/sysconfig/pgsql How ? On Mandrake 9.2 & 10 putting PGDATA in the .bash_profile file, works when using the pg_ctl command in the command line (if using bash for this user). Many thanks ! Luc Rolland
=?iso-8859-1?Q?Secr=E9tariat?= <ets@rolland-fr.com> writes: > I edit /etc/rc.d/init.d/postgresql, > and I replace the values for PGDATA with the path to my database. > Now I can connect the PC when I use : > service postgresql start > It was due to an update from PG 7.3 to PG 7.4 who has modified the init > script postgresql ! That's exactly why it's considered a bad idea to edit an init script directly --- since it's a package-supplied file, it'll be overwritten any time you update the package. > Is it possible to avaid this problem by using the : > /etc/sysconfig/pgsql That's what it's for --- you put the variable definitions in there instead, and they'll not be touched in a package update. regards, tom lane