Is postgres installed?

Поиск
Список
Период
Сортировка
Искать

Is postgres installed?

От:
christophe.andre@elsys-design.com
Дата:
Hi,

How I know whether Postgres is already installed or not on a machine(on
Linux and Windows)?
I found that pg_ctl --version could be used or I also tried to check into
the registry (for windows HKLM\SOFTWARE\PostgreSQL\Installations), however
with Windows Server 2003 pg_ctl is not recognized (probably not in the
path) and the registries are not written (nothing appears under
HKLM\SOFTWARE\)

Is there another check I can do?

Thanks
Christophe

Re: Is postgres installed?

От:
"Rob Richardson" <Rob.Richardson@rad-con.com>
Дата:
What about searching your hard drive for pg_ctl.exe? 

RobR

Re: Is postgres installed?

От:
Raymond O'Donnell <rod@iol.ie>
Дата:
On 21/05/2010 14:43, christophe.andre@elsys-design.com wrote:

> How I know whether Postgres is already installed or not on a machine(on
> Linux and Windows)?
> I found that pg_ctl --version could be used or I also tried to check into
> the registry (for windows HKLM\SOFTWARE\PostgreSQL\Installations), however
> with Windows Server 2003 pg_ctl is not recognized (probably not in the
> path) and the registries are not written (nothing appears under
> HKLM\SOFTWARE\)

On Windows, you could just have a look in c:\program files\postgresql.
There are usually some items in the Start Menu also.

On Linux, you'll see if it's actually running by doing

  ps ax | grep postgres

or the like... If it's not running, where you'd look for the files
varies from one distro to another, but using "find" should throw up some
of them.

Ray.


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

Re: Is postgres installed?

От:
Craig Ringer <craig@postnewspapers.com.au>
Дата:
On 21/05/2010 9:43 PM, christophe.andre@elsys-design.com wrote:
> Hi,
>
> How I know whether Postgres is already installed or not on a machine(on
> Linux and Windows)?
> I found that pg_ctl --version could be used

Only if PostgreSQL's binary directory is on the PATH, which it may not 
be especially on Windows.

There's no reliable way to detect a PostgreSQL install on UNIX/Linux/BSD 
either. You can look for pg_ctl on the path and tell the user that the 
pg_ctl for the postgresql install they want to use simply must be on the 
path. However, some Linux flavours support parallel installation of 
multiple versions of PostgreSQL (and multiple clusters for a given 
version), and will *not* have pg_ctl on the path for versions of 
PostgreSQL installed on the system.

On Ubuntu/Debian you'll only find `pg_ctlcluster', which is a pg_ctl 
wrapper that takes additional 'version' and 'cluster' arguments. On 
these systems you can use pg_lsclusters to find PostgreSQL clusters.

Alternately, you could simply require the user to set up the PATH 
manually, eg

   PATH=/usr/lib/postgresql/8.4/bin:$PATH  ./yourprogram

which will work anywhere and everywhere there's a Pg install.

> or I also tried to check into
> the registry (for windows HKLM\SOFTWARE\PostgreSQL\Installations), however
> with Windows Server 2003 pg_ctl is not recognized (probably not in the
> path) and the registries are not written (nothing appears under
> HKLM\SOFTWARE\)

How was Pg installed? Using which installer package?

Here (Vista, XP and Windows 7) Pg appears under
    HKLM\Software\Postgresql\Installations\postgresql-8.4
as installed by the EnterpriseDB "one-click" installer.

If you "installed" Pg from the zip file, there's no real way to figure 
out if it's installed except checking the PATH for pg_ctl.exe or 
checking the running process list for postgres.exe . Both are fallible - 
the former if pg_ctl isn't on the path, the latter if PostgreSQL is 
installed but not currently running.

--
Craig Ringer
FAQ