Unable to install postgreSQL 9.6 in Ubuntu 18.04
After few months I had to erase and install from scratch, so in order to install postgresql 9.6 I followed next steps:
Important notes: If you have already installed postgresql 10 and you want 9.6, you need to remove postgresql 10 completely and then manually install postgresql 9.6, so follow method 2.
Method 1
Step 1
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
Step 2
wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add -
Step 3.
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install postgresql-9.6
Method 2
In order to install postgres 9.6 having already postgres 10 or other version different from 9.6 installed, you need first to uninstall postgresql (any version and file related) completely following the next steps.
sudo apt-get --purge remove postgresql
dpkg -l | grep postgres (to look for postgresfiles in the system)
sudo rm -rf postgresql ... (remove all the files that appeared in the list after running the previous command)
Finally install manually postgreSQL with the next command:
sudo apt-get install postgresql-9.6
I hope it can help somebody that could have the same problem.