Source: Install and configure MySQL / MariaDB (Ubuntu)
To delete MySQL, first run the following command to make sure it’s not running:
> sudo systemctl stop mysql
Then remove MySQL and any of its related packages:
> sudo apt remove --purge mysql-*
Remove the MySQL data directory, configuration file, and logs:
> sudo rm -rf /usr/bin/mysql /var/lib/mysql /etc/mysql /var/log/mysql
Remove any packages that were automatically installed because they were dependencies of MySQL:
> sudo apt-get autoremove
MySQL is now uninstalled.