How To Remove PostgreSQL

Reading Time: 2 minutes

Sometimes during a software install, things go sideways and you realize that not all of the program downloaded or the install was interrupted for some reason leaving you with incomplete files and empty directories. Honestly, this is an rare occurance but it can happen from time to time. This then begs the question; So how do I completely uninstall recently installed software? In this tutorial, we’ll be safely removing PostgreSQL from our Liquid Web Ubuntu 16.04 server.  

 

 

 

Note
It’s essential to back up any databases you may need, do so before making deletions to your system.

Step 1: List the PostgreSQL Packages

Use the dpkg tool to list packages pertaining to the PostgreSQL setup.

dpkg -l | grep postgres

Output:

 

 

 

Step 2: Delete the PostgreSQL Packages

In Step 1, all of the software packages related to the PostgreSQL install are shown. To remove and delete them all with one command, Start with the
apt-get --purge remove command
followed by each package name indicated separated with a space.  For my particular version of PostgreSQL, the software installed was: 

  • pgdg-keyring
  • postgresql-10
  • postgresql-client-10
  • postgresql-client-common
  • postgresql-common

so, my purge remove command will look like this:

sudo apt-get --purge remove pgdg-keyring postgresql-10 postgresql-client-10 postgresql-client-common postgresql-common

Step 3:  Verifying the Deletion of PostgreSQL

Once you remove these packages you should no longer be able to enter into the PostgreSQL environment.  You can verify that by running the grep command again and searching for postgres:

root@newclient:~# dpkg -l | grep postgres
root@newclient:~#

As you can see, there is no output from that command which means, postgreSQL has been sucessfully uninstalled! 

 

If you have other thoughts or questions, our Sales and Support teams are standing by 24 hours a day by phone or e-mail to assist. Reach out to us by opening a support ticket at support@liquidweb.com, giving us a call at 1-800-580-4985 or, open a chat with us and we’ll be happy to answer any questions you may have!

Thank for hosting with Liquidweb!

Video by: Justin Palmer

 

Here's 75 % off, Launch a New VPS Today. Find out why 30,000 customers have chosen our Best-in-Class Performance & 24x7 Heroic Support