Uninstall MySQL Completely on Debian, Ubuntu, Linux Mint, Pop!_OS, Elementary OS
Last modified on .
If you encounter some technical problems with a package on Linux, the first thing you do is probably try to reinstall it. But the configuration is still there after the package is removed, so everything goes right back to the start after reinstalling it. That's why this guide will cover how to completely purge MySQL.
Stop Service
Stop the MySQL service (mysql.service
) first so no more data will be written to the disk:
$ sudo systemctl stop mysql
Uninstall Packages
Remove the MySQL packages:
-
All packages related to MySQL (including tools, client, etc.)
$ sudo apt purge mysql*
-
MySQL server only
$ sudo apt purge mysql-server
Remove the unused dependencies:
$ sudo apt autoremove
Remove Configurations (Optional)
Remove the configuration files at /etc/mysql
:
$ sudo rm -rf /etc/mysql
Remove Databases (Optional)
Remove the database storage at /var/lib/mysql
:
$ sudo rm -rf /var/lib/mysql