How do I uninstall MySQL?

I installed MySQL using sudo apt-get. Now I need to remove it from my system.

How can I do that?


I assume that you don't need MySQL anymore and you have already taken backup of your important databases. I suggest you to take backup of your important MySQL databases.

Note: Your all mysql data will be lost.

First make sure that MySQL service is stopped.

sudo systemctl stop mysql

Remove MySQL related all packages completely.

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

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

(Optional) Remove unnecessary packages.

sudo apt autoremove

(Optional) Remove apt cache.

sudo apt autoclean

all the above solutions are correct but I would try with

sudo apt-get remove --purge mysql*
sudo apt-get autoremove
sudo apt-get autoclean

This will uninstall all mysql related packages.


This will remove mysql 5.6 from ubuntu 15.04

sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean
sudo rm -rf /var/lib/mysql
sudo rm -rf /etc/mysql