How To Remove PostgreSQL

Reading Time: 1 minute

Let’s say you were trying to download PostgreSQL and you realize that not all of the program downloaded, leaving you with files and directories that are taking up space on your server, and begs the question: How do you completely uninstall PostgreSQL?  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:

To remove PostgreSQL from your server use the dkpg command to first find the packages to remove.

Step 2: Delete the PostgreSQL Packages

In Step 1, you’ll see packages to delete and delete them with one command. Start with apt-get –purge remove followed by each package name separated with a space.  For my particular version of PostgreSQL my command looks like this:

sudo apt-get --purge remove postgresql-9.5 postgresql-client-9.5 postgresql-client-common postgresql-common postgresql-contrib postgresql-contrib-9.5

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 trying to switch to PostgreSQL default user (postgres) or enter into a database.

 

Author Bio

About the Author: Echo Diaz

Throughout Echo's four year stint as a technical support specialist, her passion for breaking down complex concepts has to lead to a career in professional writing. As a top tier support specialist, she adds a distinctive element to her written work that speaks to customer feedback and concerns.

Echo occasionally pops her head out from behind her computer to watch her dog energetically run around the yard and unabashedly shovels money into buying tickets to see her favorite musical artists.

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