How to remove MySQL on Ubuntu or Debian

Question: I have MySQL installed by apt-get on Ubuntu. What is a proper way to uninstall and remove MySQL on Ubuntu (or Debian, Linux Mint)?

First of all, stop MySQL server if it's running.

$ sudo service mysql stop

If you want to remove MySQL completely, use the following commands. This will uninstall MySQL server/client packages, remove MySQL configuration files, wipe out MySQL data directory (e.g., /var/lib/mysql), and delete mysql user ID. Essentially everything related to MySQL.

$ sudo apt-get remove --purge mysql-server mysql-client mysql-common
$ sudo apt-get autoremove
$ sudo apt-get autoclean

If you want to remove MySQL related packages only, but keep the rest of MySQL related config and data files, use the following commands instead. This is useful when you are upgrading MySQL.

$ sudo apt-get remove mysql-server mysql-client mysql-common
$ sudo apt-get autoremove
$ sudo apt-get autoclean

Download this article as ad-free PDF (made possible by your kind donation): 
Download PDF

Subscribe to Ask Xmodulo

Do you want to receive Linux related questions & answers published at Ask Xmodulo? Enter your email address below, and we will deliver our Linux Q&A straight to your email box, for free. Delivery powered by Google Feedburner.


Support Xmodulo

Did you find this tutorial helpful? Then please be generous and support Xmodulo!

Leave a comment

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