In Linux systems, MySQL database is a very commonly used relational database management system, but in some cases we need to delete MySQL. This article will introduce how to delete the MySQL database in Linux system.
Before performing the deletion operation, we need to confirm the specific version of MySQL. You can use the following command to check:
mysql --version
The output is similar to:
mysql Ver 14.14 Distrib 5.7.31, for Linux (x86_64) using EditLine wrapper
Before deleting MySQL, we need to stop it. Running MySQL service. Stop the MySQL service using the following command:
sudo systemctl stop mysql
If your system is using the old system V init script, you can stop the MySQL service using the following command:
sudo /etc/init.d/mysql stop
After stopping the MySQL service, we need to uninstall the MySQL package. Use the following command to uninstall the MySQL package:
sudo apt-get remove mysql-server
If you need to delete the MySQL configuration file and data at the same time, you can use the following command:
sudo apt-get purge mysql-server sudo apt-get autoremove
If you choose to delete the MySQL configuration file and data, you need to manually delete the MySQL data file. The following is the default storage location for MySQL data files:
/var/lib/mysql/
Use the following command to delete the MySQL data files:
sudo rm -R /var/lib/mysql/
Even if you MySQL has been uninstalled, and there may still be residual files. Use the following command to clean up MySQL residual files:
sudo find / -iname 'mysql*'
This command will search for all matching MySQL files in the entire file system. You can delete files based on search results.
Deleting MySQL requires careful handling to avoid accidentally deleting files or data. Before performing the deletion operation, make sure you have backed up all important data. Through this article, you should have mastered the method of deleting MySQL database in Linux system.
The above is the detailed content of linux delete mysql. For more information, please follow other related articles on the PHP Chinese website!