Home > Database > Mysql Tutorial > body text

delete mysql linux

王林
Release: 2023-05-18 09:31:37
Original
1154 people have browsed it

On Linux systems, MySQL is a common relational database management system. But sometimes, we may need to delete MySQL. This article will explain how to delete MySQL on Linux.

Step 1: Shut down the MySQL service

Before deleting MySQL, you need to shut down the MySQL service first. You can use the following command:

sudo systemctl stop mysql
Copy after login

If you are not using systemd, you can use the following command:

sudo service mysql stop
Copy after login

Step 2: Uninstall MySQL

Uninstalling MySQL requires going through the package manager conduct. You can check if MySQL is installed using the following command:

dpkg -l | grep mysql
Copy after login

If MySQL is already installed, an output similar to the following will be displayed:

ii  libmysqlclient18:amd64        5.5.46-0ubuntu0.14.04.2       amd64        MySQL database client library
ii  mysql-common                  5.5.46-0ubuntu0.14.04.2       all          MySQL database common files, e.g. /etc/mysql/my.cnf
ii  mysql-server-5.5              5.5.46-0ubuntu0.14.04.2       amd64        MySQL database server binaries and system database setup
Copy after login

Now, you can uninstall MySQL using the following command:

sudo apt-get remove --purge mysql-server mysql-client mysql-common
Copy after login

This command will delete the MySQL server, client and public files. If you also want to delete the MySQL data directory, please use the following command:

sudo rm -rf /var/lib/mysql
Copy after login

Step 3: Delete the MySQL configuration file

Before deleting the MySQL configuration file, you can use the following command to check which files are installed :

dpkg -L mysql-server
Copy after login

This will display a file list of all installed MySQL servers. If you want to delete the MySQL configuration file, use the following command:

sudo rm /etc/mysql/ -R
Copy after login

Step 4: Delete MySQL users and groups

The last step is to delete the MySQL users and groups. MySQL users and groups can be deleted using the following command:

sudo deluser mysql
sudo delgroup mysql
Copy after login

Now, you have successfully deleted MySQL from your Linux system.

Summary

Deleting MySQL on a Linux system is very simple and can be completed in just a few steps. First shut down the MySQL service and then use the package manager to uninstall MySQL. Next delete the MySQL data directory and configuration files, and finally delete the MySQL users and groups. Before deleting, make sure to back up all important data and follow the above steps carefully.

The above is the detailed content of delete mysql linux. 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