Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

In my ubuntu 12.04 x64 I installed PostgreSQL 8.4. It got automatically upgraded to 9.1.1. Due to some inconsistencies, I want to downgrade it to 8.4. How can I do this using the terminal?

share|improve this question

2 Answers 2

I am not sure downgrading is the best thing to do here. After all there are reasons why upgrades are made. I do understand that there are cases in which upgrading is not obvious.

If you do want to downgrade there are two options and I strongly advice the second option.

Manually install an earlier version of PostgreSQL

Run the following commands (taken from http://colekcolek.com/2012/02/23/downgrade-postgresql-8-2-ubuntu-11-10/):

wget http://ftp.postgresql.org/pub/source/v8.4.9/postgresql-8.4.9.tar.gz
tar zxvf postgresql-8.4.9.tar.gz
cd postgresql-8.4.9
./configure --without-readline --without-zlib
make
su
make install

You will be responsible yourself for maintaining the postgres install.

Use an APT Repository

There is a repository that could help you here. In terms of maintenance that is definitely the better option. Here is an extensive quote from http://www.postgresql.org/download/linux/ubuntu/:

PostgreSQL Apt Repository

If the version included in your version of Ubuntu is not the one you want, you can use the PostgreSQL Apt Repository. This repository will integrate with your normal systems and patch management, and provide automatic updates for all supported versions of PostgreSQL throughout the support lifetime of PostgreSQL.

To use the apt repository, follow these steps:

  1. Create the file /etc/apt/sources.list.d/pgdg.list, and add a line for the repository deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main
  2. Import the repository signing key, and update the package lists
    wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
    sudo apt-get update

For more information about the apt repository, including answers to frequent questions, please see the apt page on the wiki.

There is also a PPA, but I think it is deprecated in favour of the repository: sudo add-apt-repository ppa:pitti/postgresql. More info on the same page.

Also read: How do I set which PostgreSQL version is to be used by default?

share|improve this answer

Ubuntu does not automatically upgrade PostgreSQL 8.4 to 9.1. What probably happened is that 9.1 is now installed alongside the old 8.4, and the client tools you are using prefer to connect to the 9.1 instance. Try pg_lsclusters to see what is really running on what ports they are on.

share|improve this answer

Your Answer

 
discard

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.