Saturday, September 15, 2012

Replace PostgreSQL 9.1 with 9.2 in Ubuntu 12.04

Recently released PostgreSQL 9.2 comes with a heap of new features and improvements over 9.1.

These are the steps I took to remove 9.1 and install PostgreSQL 9.2 in Ubuntu 12.04.

Warning: This procedure is suitable for test and development environments only as it will wipe out all 9.1 databases

1. List currently installed postgres packages

sudo dpkg -l | grep postgres

2. Remove postgresql-9.1

*these packages were on my system

sudo apt-get --purge remove postgresql postgresql-9.1 postgresql-client-9.1 postgresql-client-common postgresql-common postgresql-doc postgresql-doc-9.1

3. Install postgresql-9.2 with official ppa

sudo add-apt-repository ppa:pitti/postgresql
sudo apt-get update
sudo apt-get install postgresql-9.2

If you cannot add the repository
sudo: add-apt-repository: command not found

Install this package

sudo apt-get install python-software-properties

4. Check postgresql is set to the default port 5432

sudo netstat -lp | grep postgresql

5. Reset to default port if necessary

sudo gedit /etc/postgresql/9.2/main/postgresql.conf

port = 5432 *change the port value in the conf file

sudo /etc/init.d/postgresql reload

6. Setup your project database / user and database.yml

PostgreSQL Setup for Rails Development (skip to step 2)