Linux platform Uninstall MySQL summary "Go"

Source: Internet
Author: User

Recently used MySQL master and slave, see this article, take out to share a bit.

Turn from: http://www.cnblogs.com/kerrycode/p/4364465.html Xiaoxiang Hermit

 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
[[email protected] INIT.D]

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]ver 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]
[[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
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/mysq L/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/local/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]
[[email protected] INIT.D]

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
[[email protected] INIT.D]

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

Linux platform Uninstall MySQL summary "Go"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.