8

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?

1 Answer 1

21

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.

1
  • if so frustrated with ubuntu, if it was'nt my server i would have removed it completely.
    – rho
    Oct 6, 2021 at 8:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .