Uninstall MySQL Completely on Debian/Ubuntu/Linux Mint/Pop!_OS/Elementary OS

mail
Cyrus Kao
Last modified

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 still there after the package being removed, so everything goes right back to the start after reinstalling it. That's why this guide will cover how to completely purge MySQL.

/usr/sbin/mysqld
MySQL daemon (/usr/sbin/mysqld) running in the background

Stop Service

Stop the MySQL service (mysql.service) first so no more data will be written to the disk:

sudo systemctl stop mysql
Bash

Uninstall Packages

Remove the MySQL packages:

  • All packages related to MySQL (including tools, client, etc.)

    sudo apt purge mysql*
    Bash
  • MySQL server only

    sudo apt purge mysql-server
    Bash

Remove the unused dependencies:

sudo apt autoremove
Unknown

Remove Configuration (Optional)

Remove the configuration files at /etc/mysql:

sudo rm -rf /etc/mysql
Bash

Remove Data (Optional)

Remove the database storage at /var/lib/mysql:

sudo rm -rf /var/lib/mysql
Bash

See Also

Comments

0500