PostgreSQL on Ubuntu – Running Multiple Versions on the Same Server

postgresqlUbuntu

I have PostgreSQL 8.4 and 9.0 running on the same server (Ubuntu Lucid).

I installed them both via apt-get (8.4 with the default package sources, and 9.0 after adding the ppa from https://launchpad.net/~pitti/+archive/postgresql).

When I run a command like "createdb" from the command line or start up the "psql" shell, PostgreSQL version 8.4 is used by default on my system.

So, how do I force these commands to use PostgreSQL 9.0 instead of 8.4?

Best Answer

Assuming Ubuntu does the same thing as Debian, then your two PostGreSQL instances will be running on different ports.

You can easily check the config files to see which version is on which port:

$ grep -H '^port' /etc/postgresql/*/main/postgresql.conf
/etc/postgresql/8.4/main/postgresql.conf:port = 5432
/etc/postgresql/8.3/main/postgresql.conf:port = 5433

Most of the PostGreSQL commands take the "-p ####" or "--port=####" option, so you can use that to select the version you want.