17

Just recently, I've read that PostgreSQL 9.2 is released. My Ubuntu 12.04 has PostgreSQL 9.1.5 installed. How can I update to 9.2 version? I tried apt-get update and apt-get upgrade but no updates for PostgreSQL.

3 Answers 3

32

Here's the instructions for adding the postgresql apt repository: https://wiki.postgresql.org/wiki/Apt

Quickstart

Import the repository key from http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc:

wget -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -

Edit /etc/apt/sources.list.d/pgdg.list. The distributions are called codename-pgdg. In the example, replace squeeze with the actual distribution you are using:

deb http://apt.postgresql.org/pub/repos/apt/ squeeze-pgdg main

Configure apt's package pinning to prefer the PGDG packages over the Debian ones in /etc/apt/preferences.d/pgdg.pref:

Package: *
Pin: release o=apt.postgresql.org
Pin-Priority: 500

Note: this will replace all your Debian/Ubuntu packages with available packages from the PGDG repository. If you do not want this, skip this step. Update the package lists, and install the pgdg-keyring package to automatically get repository key updates:

sudo apt-get update
sudo apt-get install pgdg-keyring

Once you've added that repository, you can do sudo apt-get install postgresql-9.2

5
  • I already have PostgreSQL installed, doing this will conflict my current installed?
    – Defensor
    Feb 23, 2013 at 14:01
  • it will install in it's own folder for postgresql-9.2. If you find some of your commands (like pg_dump) point to postgresql-9.1 programs, you can change the symlink or just run the command from within the postgresql-9.2 directory. definitely back up databases before installing the new version just to be sure.
    – Danny
    Feb 23, 2013 at 16:58
  • 1
    I take issue with that deprecation warning, since the PPA goes up to Quantal and the newer repo doesn't. Both are late to Raring, which breaks the recommended script.
    – Tobu
    Apr 22, 2013 at 20:55
  • 1
    Just for future reference, I was getting the error saying /var/lib/postgresql/9.2/main is not accessible or does not exist Solved it using sudo apt-get remove --purge postgresql-9.2 postgresql-9.1 sudo apt-get install postgresql-9.2
    – Pankaj
    Jul 18, 2013 at 5:08
  • Note, piping into sudo is not recommended. On my system, that causes the sudo prompt to be hidden, making the entire command appear to hang indefinitely.
    – Cerin
    Apr 27, 2014 at 1:54
6

There is a new, official postgresql.org repository. It contains the newest versions of postgresql including 9.3 as of February 2014. Please read the detailed official instructions. For Ubuntu 12.04 I used:

sudo bash -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
sudo apt-get update
sudo apt-get install postgresql-9.3 pgadmin3
3
  • 1
    What provides the 9.3 version of pg_dump? Dpkg says it's still being provided by postgresql-client-common, which is stuck at 9.1.
    – Cerin
    Apr 27, 2014 at 2:08
  • @Cerin package postgresql-client-9.3 contains pg_dump
    – geekQ
    Apr 27, 2014 at 10:14
  • Ah you're right. But it didn't update the symlinks in /usr/bin, which I'll just have to do manually.
    – Cerin
    Apr 27, 2014 at 15:58
-1

Try this:

sudo -u postgres psql --cluster 9.2/main 
4
  • I get this : Error: Invalid version specified with --cluster
    – Defensor
    Sep 12, 2012 at 15:25
  • On Askubuntu the individual asking a question will see every answer without needing to be individually addressed. Similarly you will be notified of every comment on your answer. Welcome to the site! Do you have any suggestion about Defensor's version error message? Oct 9, 2012 at 19:57
  • 1
    This is just wrong. He's asking how to upgrade, not to connect to a 9.2 cluster. Jan 16, 2013 at 2:22
  • AS far as I know, ppa:pitti installs the 9.2 in parallel to 9.1 - it just runs on another port. try 'psql -p 5433'.
    – alfonx
    Feb 8, 2013 at 17:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .