Tuesday, July 24, 2018

How to remove Postgres from any installation

How to remove Postgres from any  installation

If your install isn't already damaged, you can drop unwanted PostgreSQL servers ("clusters") in Ubuntu using 'pg_dropcluster'. Use that in preference to a full purge and reinstall if you just want to start with a freshly 'initdb' PostgreSQL instance.

If you really need to do a full purge and reinstall, first make sure PostgreSQL isn't running.

ps -C postgres 

should show no results.

Now run:

apt-get --purge remove postgresql\*

to remove everything PostgreSQL from your system. Just purging the postgres package isn't enough since it's just an empty meta-package.

Once all PostgreSQL packages have been removed, run:

rm -r /etc/postgresql/
rm -r /etc/postgresql-common/
rm -r /var/lib/postgresql/
userdel -r postgres
groupdel postgres

You should now be able to:

apt-get install postgresql

or for a complete install:

apt-get install postgresql-9.6 postgresql-contrib-9.6 postgresql-doc-9.6




No comments:

Post a Comment