How to upgrade postgres from 9.5 to 10 on ubuntu

April 03, 2019



First backup any DB's you need. Next uninstall the old version:


sudo apt remove postgresql-9.5


and install the new version



sudo apt install postgresql-10


Now edit the conf file to change the port for version 10 to 5432 as mine was set to 5433


sudo nano /etc/postgresql/10/main/postgresql.conf
# Press ctrl+w and search for "port"
# change it to port = 5432 and save 


Now restart the service


sudo service postgresql restart


And now postgres should be 10.x!