Uninstall MySQL
Updated Oct 20, 2019 ·
Uninstall
-
Remove the installed MySQL packages, including the server and client packages:
sudo apt-get purge -y mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-* -
To remove any leftover dependencies that are no longer needed after removing MySQL:
sudo apt-get autoremove -y -
Clear any cached packages that are stored on your system to free up space:
sudo apt-get clean -
To completely remove MySQL's configuration and data files, which are not removed by the above commands, delete the following directories manually:
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql /var/log/mysql.* /var/run/mysqld -
If there are still MySQL packages on your system, you can list them and remove any remaining MySQL packages:
dpkg -l | grep mysqlIf you find any packages, remove them manually using:
sudo dpkg --purge <package-name>Sample:
sudo apt-get purge --auto-remove -y mysql-client mysql-common mysql-community-client mysql-community-client-core mysql-community-client-plugins mysql-community-server mysql-community-server-core mysql-community-server-debug mysql-community-test mysql-community-test-debugCheck again:
dpkg -l | grep mysql -
If you get an error deleting
mysql-common, inspect and edit the Post-Removal Script:sudo vi /var/lib/dpkg/info/mysql-common.postrmRun the purge command again:
sudo dpkg --purge mysql-common