Upgrading from Postgresql 9.1 to 9.3

If you have just upgraded to the latest Ubuntu LTS 14.04 (Trusty Tahr), you might encountered a problem where Postgresql 9.3 is being installed along with your older version of Postgresql. It is recommended to upgrade your current setup to 9.3 and uninstall the older version.

Before you use pg_upgrade, make sure you shut down all Postgresql instances with

service postgresql stop  

You can use the script below:

In the newer configuration file (postgresql.conf), switch the port to match the older version (from 5433 -> 5432).

Lastly,
Remove the older version using

sudo apt-get remove postgresql-9.1  

and start the newer version using

sudo service postgresql restart  

Problem

In the process of upgrading, I encountered

connection to database failed: fe_sendauth: no password supplied  

I solved it by changing both pg_hba.conf (9.1 and 9.3) to use no password.

local all postgres trust  

But, be sure to change back to previous setting before launching back your Postgresql.