Learn to Remove PostgreSQL

Occasionally, during software installation, interruptions or incomplete downloads can occur, leaving you with partial files and empty directories. Although infrequent, such incidents can occur. In such cases, the question arises: How do you completely uninstall recently installed software? This tutorial provides a step-by-step guide on safely removing PostgreSQL from an Ubuntu 16.04 server.

Before initiating the uninstallation process, it is crucial to back up any databases you may need to prevent data loss.

Step 1: List the PostgreSQL Packages

Use the dpkg tool to list the packages associated with the PostgreSQL setup.


Step 2: Uninstall PostgreSQL Packages

Building on the package list obtained in Step 1, you can efficiently remove all associated software packages with a single command. Utilize the apt-get --purge remove command followed by the names of each identified package separated by a space. As an example, considering a specific version of PostgreSQL with the following installed packages:

  • pgdg-keyring

  • postgresql-10

  • postgresql-client-10

  • postgresql-client-common

  • postgresql-common

The purge remove command would appear as follows:

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

Step 3: Verify PostgreSQL Deletion

After executing the removal command, attempting to access the PostgreSQL environment should be unsuccessful. Confirm this by rerunning the dpkg -l | grep postgres command and searching for 'postgres.' If the uninstallation was successful, there should be no output from the command, indicating that PostgreSQL has been completely removed.

This straightforward process ensures the effective removal of PostgreSQL from your system.

Was this article helpful?

mood_bad Dislike 0
mood Like 0
visibility Views: 1797