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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.