How to remove MySQL on Ubuntu or Debian

Last updated on July 15, 2020 by Dan Nanni

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 systemctl stop mysql

Or:

$ 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

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal or credit card

Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.

Xmodulo © 2021 ‒ AboutWrite for UsFeed ‒ Powered by DigitalOcean