Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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?

share|improve this question

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.

share|improve this answer

Use --cluster option e.g. (assuming that both clusters are named as default main):

psql --cluster 8.4/main
psql --cluster 9.0/main

Generic schemas are:

--cluster version/name      # for local connections
--cluster version/host:port # for TCP/IP connections

To list all installed clusters (name, port, status, data directory etc.) use pg_lsclusters command.

Check man pg_wrapper for more information.

share|improve this answer

You can use dpkg -L <packagename> to see what files a particular package owns. Run it with the postgresql 9 package and see where the createdb command for that version was stored.

Most postgresql commands would work cross-version with appropriate selection of the database by port or path, but this of course does not apply to start scripts and creation commands.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.