zoukankan      html  css  js  c++  java
  • Centos7 卸载mysql5.7详细步骤,Linux删除Mysql5.7详细操作

    ================================

    ©Copyright 蕃薯耀 2021-12-30

    https://www.cnblogs.com/fanshuyao/

    一、查看有没有安装Mysql

    1、yum 安装方式查看有没有安装的Mysql

    yum list installed mysql*

    示例:

    [root@host-101 ~]# yum list installed mysql*
     
    已加载插件:fastestmirror, langpacks
    Loading mirror speeds from cached hostfile
     * base: mirrors.aliyun.com
     * extras: mirrors.aliyun.com
     * updates: mirrors.aliyun.com
    已安装的软件包
    mysql-community-client.x86_64                            5.7.21-1.el7                            installed
    mysql-community-common.x86_64                            5.7.21-1.el7                            installed
    mysql-community-libs.x86_64                              5.7.21-1.el7                            installed
    mysql-community-server.x86_64                            5.7.21-1.el7                            installed

    删除已经安装的软件包

    yum remove mysql-community-client.x86_64  mysql-community-common.x86_64 mysql-community-libs.x86_64   mysql-community-server.x86_64   

    2、rpm 方式查看有没有安装的Mysql:

    rpm -qa | grep -i mysql

    示例:

    [root@host-101 ~]# rpm -qa | grep -i mysql
     
    mysql-community-libs-5.7.21-1.el7.x86_64
    mysql-community-client-5.7.21-1.el7.x86_64
    mysql-community-server-5.7.21-1.el7.x86_64
    mysql-community-common-5.7.21-1.el7.x86_64

    要按照顺序删除:

    rpm -e mysql-community-server-5.7.21-1.el7.x86_64
    rpm -e mysql-community-client-5.7.21-1.el7.x86_64
    rpm -e mysql-community-libs-5.7.21-1.el7.x86_64
    rpm -e mysql-community-common-5.7.21-1.el7.x86_64

    要按照顺序删除,不然会报错:依赖检测失败:

     
    [root@host-101 ~]# rpm -e mysql-community-libs-5.7.21-1.el7.x86_64
     
    错误:依赖检测失败:
        mysql-community-libs(x86-64) >= 5.7.9 被 (已安裝) mysql-community-client-5.7.21-1.el7.x86_64 需要
     
     
    [root@host-101 ~]# rpm -e mysql-community-client-5.7.21-1.el7.x86_64
     
    错误:依赖检测失败:
        mysql-community-client(x86-64) >= 5.7.9 被 (已安裝) mysql-community-server-5.7.21-1.el7.x86_64 需要

    删除完之后,再检查一下(有的话,继续删除):

    rpm -qa | grep -i mysql

    二、删除残留的mysql目录或文件:

    1、查询mysql的安装目录

    whereis mysql

    示例:

    [root@host-101 ~]# whereis mysql
     
    mysql: /usr/local/mysql /usr/share/mysql /java/mysql5.7/bin/mysql

    删除上面的文件夹

    rm -rf /usr/local/mysql
    rm -rf /usr/share/mysql
    rm -rf /java/mysql5.7/bin/mysql

    2、根据mysql的名称继续查找残留的文件,并删除:

    find / -name mysql
     
    find / -name mysqld

    示例:

    mysql:[root@host-101 ~]# find / -name mysql
     
     
    /run/lock/subsys/mysql
    /etc/selinux/targeted/active/modules/100/mysql
    /etc/selinux/targeted/tmp/modules/100/mysql
    /var/lib/mysql
    /var/lib/mysql/mysql
    /java/mysql5.7/include/mysql
    /java/mysql5.7/data/mysql

    删除上面的文件

    rm -rf /run/lock/subsys/mysql
    rm -rf /etc/selinux/targeted/active/modules/100/mysql
    rm -rf /etc/selinux/targeted/tmp/modules/100/mysql
    rm -rf /var/lib/mysql
    rm -rf /var/lib/mysql/mysql
    rm -rf /java/mysql5.7/include/mysql
    rm -rf /java/mysql5.7/data/mysql
     
    rm -rf /java/mysql5.7/bin/mysqld

    3、删除mysql 配置文件

    rm -rf /etc/my.cnf

    4、删除 /var/log/mysqld.log

    (如果不删除这个文件,会导致新安装的 mysql 无法生存新密码,导致无法登陆)

    rm -rf /var/log/mysqld.log
     
    rm -rf /var/log/mysql.log

    5、删除mysql开机自启动服务

    服务名有可能是mysql或者mysqld,具体删除根据查询出来的结果

    chkconfig --list | grep -i mysql
     
    chkconfig --del mysqld

    6、删除/etc/init.d的文件

    rm -rf /etc/init.d/mysqld 

    示例:

    [root@host-101 system]# cd /etc/init.d
    [root@host-101 init.d]# ll | grep mysql
    -rwxr-xr-x. 1 root root 10576 12月 29 16:38 mysqld
    [root@host-101 init.d]# rm -rf mysqld 

    7、删除/usr/lib/systemd/system的服务

    cd /usr/lib/systemd/system
     
     
    #查询
    ll | grep mysql
     
    #删除
    rm -rf mysqld.service
    rm -rf mysqld@.service

    (时间宝贵,分享不易,捐赠回馈,^_^)

    ================================

    ©Copyright 蕃薯耀 2021-12-30

    https://www.cnblogs.com/fanshuyao/

    今天越懒,明天要做的事越多。
  • 相关阅读:
    Java开发中的23种设计模式详解
    Zookeeper基本知识
    Zookeeper命令
    ZooKeeper原理及使用
    几种java通信(rmi,http,hessian,webservice)协议性能比较
    linux 查看系统信息命令
    Zookeeper安装和配置
    Hive 接口介绍(Web UI/JDBC)
    窗口标志-外观
    pyqt5-QWidget-窗口状态(最大化最小化等)
  • 原文地址:https://www.cnblogs.com/fanshuyao/p/15749255.html
Copyright © 2011-2022 走看看