Home > Database > Mysql Tutorial > linux delete mysql

linux delete mysql

PHPz
Release: 2023-05-18 10:52:37
Original
1738 people have browsed it

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.

  1. Confirm MySQL version

Before performing the deletion operation, we need to confirm the specific version of MySQL. You can use the following command to check:

mysql --version
Copy after login

The output is similar to:

mysql  Ver 14.14 Distrib 5.7.31, for Linux (x86_64) using  EditLine wrapper
Copy after login
  1. Stop the MySQL service

Before deleting MySQL, we need to stop it. Running MySQL service. Stop the MySQL service using the following command:

sudo systemctl stop mysql
Copy after login

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
Copy after login
  1. Uninstall the MySQL software Package

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
Copy after login

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
Copy after login
  1. Delete the data file

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/
Copy after login

Use the following command to delete the MySQL data files:

sudo rm -R /var/lib/mysql/
Copy after login
  1. Clean MySQL residual files

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*'
Copy after login

This command will search for all matching MySQL files in the entire file system. You can delete files based on search results.

  1. Conclusion

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template