How to Uninstall PostgreSQL on Ubuntu 22.04

To completely remove or uninstall PostgreSQL database on Ubuntu 22.04, there are 2 easiest ways for that, firstly you can use the sudo apt-get remove --purge postgresql command on the terminal and secondly, you can do it by Ubuntu Software Center.

How to Uninstall PostgreSQL on Ubuntu 22.04

Here are two options to completely remove PostgreSQL on ubuntu 22.04:

Option 1: Remove PostgreSQL From Terminal

This is the first and easiest way to remove PostgreSQL from an Ubuntu system via terminal or command line using some snap and appropriate commands:

Step 1: Open Terminal

Press ctrl+alt+t on keyboard to start terminal window or command line.

Step 2: Uninstall PostgreSQL Snap Ubuntu 22.04

To run sudo snap remove PostgreSQL command on terminal window and press enter to completely remove PostgreSQL application from ubuntu 22.04 system:

sudo systemctl disable postgresql
sudo apt-get remove --purge postgresql

Step 3: Remove Dependent Packages

To remove packages or dependencies related to PostgreSQL you need to run the clean or clear command on a terminal window:

sudo apt-get autoremove

Step 4: Verify Uninstallation

Now, you can type PostgreSQL on the terminal window and press Enter to verify the uninstallation:

PostgreSQL

Option 2: Remove PostgreSQL From Ubuntu software center

The second option is more easiest way to remove PostgreSQL from an Ubuntu system.

In just 4 steps, you can uninstall PostgreSQL in Ubuntu:

  • Go to the Ubuntu software center
  • Type PostgreSQL on the Search Bar for Find PostgreSQL DB
  • Select PostgreSQL to Uninstall it
  • Confirm uninstallation of PostgreSQL Database

If there is some reason why the PostgreSQL application is not being removed from your Ubuntu Linux server or system, and you have tried many times to get it removed, don’t worry, The simplest way to do this is to you just open your terminal window and type sudo rm -rf /etc/postgresql && sudo rm -rf /var/lib/postgresql command into it as a root user, it will completely delete the PostgreSQL application from your system:

sudo rm -rf /etc/postgresql
sudo rm -rf /var/lib/postgresql

To install PostgreSQL on Ubuntu, you can reinstall it by following this guide: How to install latest postgreSQL on ubuntu 22.04.

Conclusion

That’s it; you have learned two ways on how to completely remove or uninstall postgresql application on ubuntu 22.04 linux server.

Recommended Linux Ubuntu Tutorials

AuthorDevendra Dode

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

Your email address will not be published. Required fields are marked *