Upgrade PostgreSQL from 9.1 to 9.3 on Ubuntu

At the time of writing, you could not install postgreSQL 9.3 on Ubuntu using apt-get. Here is simple instruction of updating postgreSQL on Ubuntu to v9.3
#install dependency
sudo apt-get update
sudo apt-get -y install python-software-properties
#add repository
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
#setuop repository
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" >> /etc/apt/sources.list.d/postgresql.list'
#install
sudo apt-get install postgresql-9.3 postgresql-server-dev-9.3 postgresql-contrib-9.3
#upgrade
sudo su -l postgres
psql -d template1 -p 5433
CREATE EXTENSION IF NOT EXISTS hstore;
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
\q #logout from database
service postgresql stop
/usr/lib/postgresql/9.3/bin/pg_upgrade -b /usr/lib/postgresql/9.1/bin -B /usr/lib/postgresql/9.3/bin -d /var/lib/postgresql/9.1/main/ -D /var/lib/postgresql/9.3/main/ -O " -c config_file=/etc/postgresql/9.3/main/postgresql.conf" -o " -c config_file=/etc/postgresql/9.1/main/postgresql.conf"
exit # logout postgresql back to previous user
sudo apt-get remove postgresql-9.1
sudo vim /etc/postgresql/9.3/main/postgresql.conf # find old port of 5433 and change it to 5432
sudo service postgresql restart
Issues you may encounter: when you run the real update command above (/usr/lib/postgresql/9.3/bin/pg_upgrade...), you may notice failure and show error of "Problem of connection to database failed: fe_sendauth: no password supplied " The solution would be modify pg_hba.conf of two data directories in trust mode (NO PASSWORD) authentication then re-run pg_upgrade command. Example, # Database administrative login by Unix domain socket local all postgres trust

4 comments:

  1. Awesome! Worked painlessly on my ubuntu 12.04 server.

    But just before line:

    $ sudo apt-get install postgresql-9.3 postgresql-server-dev-9.3 postgresql-contrib-9.3

    You have to run:

    $ sudo apt-get update

    Otherwise, you'll end up with not finding those packages.

    ReplyDelete
  2. Also worked painlessly from 9.2 to 9.3 by just changing the 9.1 to 9.2 in the right places

    ReplyDelete
  3. You may need to add postgress sources before update

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

    ReplyDelete
    Replies
    1. Thank you for pointing out. Yes you are absolutely right.

      Delete

Datatable static image not found on the server

When you use ```datatables.min.css``` and ```datatables.min.js``` locally, instead of datatables CDN, you may have encountered that ```sort...