How do I reinstall PostgreSQL 9.5 on Ubuntu Xenial (16.04.1)?
I've experimented with PostgreSQL config files on my workstation and then decided to revert them to the initial state by reinstalling the package. I've deleted the entire config directory for PostgreSQL (rm -Rf /etc/postgresql
), then uninstalled all the PostgreSQL packages.
Now, when I do sudo apt-get install postgresql
, it gets installed, but /etc/postgresql
directory is not re-created and I can't start the server.
What's gone wrong and how do I re-install PostgreSQL completely from scratch?
I've finally managed to resolve the problem. The installer failed to create a config, because the previous data directory was present (it's not deleted by the uninstall command).
So, in order to completely reinstall the PostgreSQL do the following:
sudo apt-get --purge remove postgresql-*
sudo rm -Rf /etc/postgresql /var/lib/postgresql
sudo apt-get install postgresql
It should install the shiny new cluster for you with clean data and config files.