This article is half-done without your Comment! *** Please share your thoughts via Comment ***
In this post, I am sharing necessary steps to remove or uninstall PostgreSQL 9.6 from Ubuntu OS. Yesterday, I was testing a few latest extensions in my PostgreSQL test server, and unfortunately, PostgreSQL Server corrupted.
As this is my test server, so simply I uninstalled full setup and again installed it.
Please check below commands which I applied to uninstalled PostgreSQL:
First check Postgres related folders:
1 |
ubuntu@ip:~/anvesh$ dpkg -l | grep postgres |
Result:
1 2 3 4 5 6 |
ii pgdg-keyring 2014.1 all keyring for apt.postgresql.org ii postgresql-9.6 9.6.1-2.pgdg14.04+1 amd64 object-relational SQL database, version 9.6 server ii postgresql-client-9.6 9.6.1-2.pgdg14.04+1 amd64 front-end programs for PostgreSQL 9.6 ii postgresql-client-common 178.pgdg14.04+1 all manager for multiple PostgreSQL client versions ii postgresql-common 178.pgdg14.04+1 all PostgreSQL database-cluster manager ii postgresql-contrib-9.6 9.6.1-2.pgdg14.04+1 amd64 additional facilities for PostgreSQL |
Command to remove few postgres folders:
1 |
ubuntu@ip:~/anvesh$ sudo apt-get --purge remove postgresql postgresql-doc |
Now check again Postgres related folders:
1 |
ubuntu@ip:~/anvesh$ dpkg -l | grep postgres |
Result:
1 2 3 |
ii pgdg-keyring 2014.1 all keyring for apt.postgresql.org ii postgresql-client-9.6 9.6.1-2.pgdg14.04+1 amd64 front-end programs for PostgreSQL 9.6 ii postgresql-client-common 178.pgdg14.04+1 all manager for multiple PostgreSQL client versions |
Now remove all other pending folders:
1 |
ubuntu@ip:~/anvesh$ sudo apt-get --purge remove postgresql postgresql-client-9.6 postgresql-common pgdg-keyring |
Now PostgreSQL is uninstalled so confirmt that PSQL is running or not:
1 2 3 |
ubuntu@ip:~/anvesh$ psql The program 'psql' is currently not installed. You can install it by typing: sudo apt install postgresql-client-common |
Now check the Postgres service status:
1 2 3 4 |
ubuntu@ip:~/anvesh$ sudo service postgresql status ● postgresql.service Loaded: not-found (Reason: No such file or directory) Active: inactive (dead) |