How to uninstall MySQL database under Linux? The following summarizes and collated the Linux platform to uninstall MySQL method. There are three main ways to install MySQL: Binary package installation (Using Generic Binaries), RPM package installation, and source installation. For different installation methods, the steps for unloading are somewhat different. If there are deficiencies or incorrect in the article, please point out or add!
RPM Package Installation method MySQL Uninstall
1: Check if the MySQL component is installed.
[Email protected] init.d]# Rpm-qa | Grep-i MySQL
mysql-devel-5.6.23-1.linux_glibc2.5
mysql-client-5.6.23-1.linux_glibc2.5
mysql-server-5.6.23-1.linux_glibc2.5
As shown above, the client, server, and devel three components of the MySQL 5.6.23 version are installed.
2: Turn off MySQL service before uninstalling
2.1 Method 1
[[Email protected] init.d]# service MySQL status
MySQL running (25673) [OK]
[[Email protected] init.d]# service MySQL stop
Shutting down MySQL. [OK]
[[Email protected] init.d]# service MySQL status
MySQL is not running[failed]
2.2 Method 2
[Email protected] init.d]#./mysql status
MySQL running (26215) [OK]
[[email protected] init.d]#./mysql stop
Shutting down MySQL. [OK]
[Email protected] init.d]#./mysql status
MySQL is not running[failed]
[Email protected] init.d]# Chkconfig--list | Grep-i MySQL
MySQL 0:off 1:off 2:on 3:on 4:on 5:on 6:off
3. Collect the folder information for MySQL
[[email protected] init.d]# Whereis MySQL
MySQL:/usr/bin/mysql/usr/include/mysql/usr/share/mysql/usr/share/man/man1/mysql.1.gz
The best practical find command to view MySQL database related files, easy to remove MySQL after completely.
[[email protected] init.d]# Find/-name MySQL
/etc/rc.d/init.d/mysql
/etc/logrotate.d/mysql
/var/lock/subsys/mysql
/var/lib/mysql
/var/lib/mysql/mysql
/usr/include/mysql
/usr/include/mysql/mysql
/usr/bin/mysql
/usr/share/mysql
/usr/lib64/mysql
4: Uninstall remove MySQL various components
[Email protected] init.d]# Rpm-ev mysql-devel-5.6.23-1.linux_glibc2.5
[Email protected] init.d]# Rpm-ev mysql-server-5.6.23-1.linux_glibc2.5
You have new mail in/var/spool/mail/root
[Email protected] init.d]# Rpm-ev mysql-client-5.6.23-1.linux_glibc2.5
[Email protected] init.d]#
5: Delete the folder that corresponds to MySQL
Check that the individual MySQL folders are cleaned and removed cleanly.
[[email protected] init.d]# Whereis MySQL
Mysql:
[[email protected] init.d]# Find/-name MySQL
/var/lib/mysql
/var/lib/mysql/mysql
/usr/lib64/mysql
[Email protected] init.d]# Rm-rf/var/lib/mysql
[Email protected] init.d]# Rm-rf/var/lib/mysql/mysql
[Email protected] init.d]# Rm-rf/usr/lib64/mysql
6: Delete MySQL users and user groups
If necessary, delete the MySQL user and the MySQL user group.
[Email protected] ~]# MORE/ETC/PASSWD | grep MySQL
Mysql:x:101:501::/home/mysql:/bin/bash
[Email protected] ~]# More/etc/shadow | grep MySQL
Mysql:!! : 16496::::::
[Email protected] ~]# More/etc/group | grep MySQL
mysql:x:501:
[[email protected] ~]# Userdel MySQL
[[email protected] ~]# Groupdel MySQL
Groupdel:group MySQL does not exist
7: Confirm whether MySQL uninstall delete
[Email protected] init.d]# Rpm-qa | Grep-i MySQL
MySQL Uninstall binary package/source installation mode
If MySQL is installed with a binary package, then you cannot find any MySQL components with the following command. So if you don't know how to install MySQL, don't use the following command to determine if MySQL is installed
[Email protected] init.d]# Rpm-qa | Grep-i MySQL
1: Check the MySQL service and close the service process .
First through the process to see if there is a status of MySQL service, as shown below, the MySQL service is started.
[Email protected] init.d]# Ps-ef | grep MySQL
Root 4752 4302 0 22:55 pts/1 00:00:00 more/etc/init.d/mysql.server
Root 7176 1 0 23:23 pts/1 00:00:00/bin/sh/usr/local/mysql/bin/mysqld_safe--datadir=/usr/local/mysql/data- -pid-file=/usr/local/mysql/data/db-server.localdomain.pid
MySQL 7269 7176 23:23 pts/1 00:00:01/usr/local/mysql/bin/mysqld--basedir=/usr/local/mysql--datadir=/usr/loca L/mysql/data--plugin-dir=/usr/local/mysql/lib/plugin--user=mysql--log-error=/usr/local/mysql/data/ Db-server.localdomain.err--pid-file=/usr/local/mysql/data/db-server.localdomain.pid
Root 7321 4302 0 23:23 pts/1 00:00:00 grep mysql
[Email protected] init.d]#/etc/init.d/mysql.server status
MySQL running (7269) [OK]
[[email protected] init.d]#/etc/init.d/mysql.server stop
Shutting down MySQL. [OK]
[Email protected] init.d]#/etc/init.d/mysql.server status
MySQL is not running[failed]
2: Find the MySQL installation directory and remove it completely
[[email protected] init.d]# Whereis MySQL
MySQL:/usr/local/mysql
[[email protected] init.d]# Find/-name MySQL
/var/spool/mail/mysql
/usr/local/mysql-5.7.5-m15-linux-glibc2.5-x86_64/include/mysql
/usr/local/mysql-5.7.5-m15-linux-glibc2.5-x86_64/bin/mysql
/usr/local/mysql-5.7.5-m15-linux-glibc2.5-x86_64/data/mysql
/usr/local/mysql
[Email protected] init.d]# rm-rf/usr/local/mysql-5.7.5-m15-linux-glibc2.5-x86_64/
[Email protected] init.d]# rm-rf/usr/local/
[Email protected] init.d]# Rm-rf/var/spool/mail/mysql
3: Delete some configuration files
Profiles typically have/etc/my.cnf or/etc/init.d/mysql.server, depending on the configuration of the installation.
4: Delete MySQL user and user group
[[email protected] ~]# ID mysql
uid=101 (MySQL) gid=501 (MySQL) groups=501 (MySQL) context=root:system_r:unconfined_t:systemlow-systemhigh
[[email protected] ~]# Userdel MySQL
Resources
Http://blog.itblood.com/completely-uninstall-the-mysql-under-linux-graphic-tutorials.html
Linux Platform Uninstall MySQL summary