Upgrade PostgreSQL

older/wrong versions.

First check which PostgreSQL is running

[email protected]:~$ sudo service postgresql status

Probably this will list version 9.3 running on port 5432.

Add the PostgreSQL repository to the sources to be able to update to newer versions.

[email protected]:~$ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
[email protected]:~$ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

Now update the system to retrieve data from the new repository.

[email protected]:~$ sudo apt-get update
[email protected]:~$ sudo apt-get upgrade

Next we can install version 9.4 of PostgreSQL.

[email protected]:~$ sudo apt-get install postgresql-9.4

If you check the status again, you will see two instances of PostgreSQL running.

[email protected]:~$ sudo service postgresql status

Optionally the old version can be removed.

ji[email protected]:~$ sudo apt-get remove --purge postgresql-9.3