How to uninstall MySQL from Ubuntu

How to uninstall MySQL from Ubuntu

In this article, we will see how to uninstall MySQL from Ubuntu.

Important Note: I suggest you to take backup of your important MySQL databases. Once we uninstall, all your MySQL data will be lost.

1. Stop MySQL server using below command.

sudo systemctl stop mysql

2. Remove all MySQL related packages completely using below command.

sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*

How to uninstall MySQL from Ubuntu

3. Remove MySQL configuration and data.
If you have changed database location in your MySQL configuration, you need to replace /var/lib/mysql according to it.

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

4. Now run optional commands.

sudo apt autoremove sudo apt autoclean

5. Lets search for all the package names installed that contain the sub-string mysql.

No packages found.

So, in this article we have explained step by step to uninstall MySQL from Ubuntu Linux server.