You would like to remove MySQL database from your Ubuntu system ? In this short tutorial, you will learn how to safely uninstall MySQL .
Make sure however to create backups of your databases before starting the procedure. In case you have an issue with MySQL, you also have the possibility to repair MySQL.
Read: How to install MySQL on Ubuntu 18.04
If MySQL service is up and running, you would need to stop it using the command :
sudo systemctl stop mysql
Uninstall MySQL Ubuntu: Stop service
You also have to delete any process/daemon related to MySQL by invoking the commands:
sudo killall -9 mysql
sudo killall -9 mysqld
Read: How to install LAMP on Ubuntu 18.04
Now the most important commands that will completely remove MySQL (along with its dependent packages) are the following :
sudo apt-get remove –purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*
If you had configured your MySQL and created some data, this also needs to be removed for a clean uninstallation.
sudo rm -rf /var/log/mysql
sudo rm -rf /etc/mysql
sudo rm -rf /usr/bin/mysql
sudo deluser -f mysql
Finally carry out the following set of commands to get rid of packages that are no longer necessary:
sudo apt autoremove
sudo apt autoclean
Remove MySQL Ubuntu: Autoclean command
If you like the content, we would appreciate your support by buying us a coffee. Thank you so much for your visit and support.
This Post Has One Comment
Thanks for help us. I saw one error in the 3rd command. “The word ‘remove’ will come after ‘–purge’ only. If we use before , it will show error