• Linux彻底卸载MySQL


    Linux彻底卸载MySQL

    1. 查找是否装有mysql

    [root@centos7 ~]#rpm -qa |grep mysql
    [root@centos7 ~]#ss -ntl
    State      Recv-Q Send-Q              Local Address:Port                             Peer Address:Port
    LISTEN     0      128                             *:22                                          *:*
    LISTEN     0      100                     127.0.0.1:25                                          *:*
    LISTEN     0      128                          [::]:22                                       [::]:*
    LISTEN     0      100                         [::1]:25                                       [::]:*
    LISTEN     0      80                           [::]:3306                                     [::]:*
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    2. 停止mysql服务并删除mysql

    [root@centos7 ~]#systemctl stop mysqld.service
    [root@centos7 ~]#rpm -ev mysql*
    
    • 1
    • 2

    3. 删除mysql的目录文件和库

    [root@centos7 ~]#find / -name mysql
    /etc/selinux/targeted/active/modules/100/mysql
    /data/mysql
    /data/mysql/mysql
    /usr/lib64/mysql
    /usr/local/mysql-5.7.30-linux-glibc2.12-x86_64/bin/mysql
    /usr/local/mysql-5.7.30-linux-glibc2.12-x86_64/include/mysql
    /usr/local/mysql
    /usr/share/mysql
    /var/lib/mysql
    
    [root@centos7 ~]#rm -rf /var/lib/mysql
    [root@centos7 ~]#rm -rf /usr/share/mysql
    [root@centos7 ~]#rm -rf /usr/local/mysql*
    [root@centos7 ~]#rm -rf /data/mysql*
    [root@centos7 ~]#rm -rf /usr/lib64/mysql
    [root@centos7 ~]#rm -rf /etc/selinux/targeted/active/modules/100/mysql
    [root@centos7 ~]#rm -rf /etc/my.cnf  #卸载后/etc/my.cnf不会删除,需要进行手工删除
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18

    4. 删除mysql用户及组

    [root@centos7 ~]#id mysql
    uid=997(mysql) gid=1001(mysql) groups=1001(mysql)
    [root@centos7 ~]#userdel -r mysql
    [root@centos7 ~]#groupdel mysql
    [root@centos7 ~]#cat /etc/passwd |grep mysql  #验证用户是否被删除
    [root@centos7 ~]#cat /etc/group |grep mysql   #验证用户组是否被删除
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    5. 再次查看是否存在mysql

    [root@centos7 ~]#rpm -qa|grep -i mysql
    
    #locate和updatedb命令来自于mlocate包
    [root@centos7 ~]#yum -y install mlocate
    [root@centos7 ~]#updatedb
    [root@centos7 ~]#locate mysql
    /etc/my.cnf.d/mysql-clients.cnf
    /etc/profile.d/mysql.sh
    /etc/rc.d/init.d/mysqld
    /etc/rc.d/rc0.d/K36mysqld
    /etc/rc.d/rc1.d/K36mysqld
    /etc/rc.d/rc2.d/S64mysqld
    /etc/rc.d/rc3.d/S64mysqld
    /etc/rc.d/rc4.d/S64mysqld
    /etc/rc.d/rc5.d/S64mysqld
    /etc/rc.d/rc6.d/K36mysqld
    /root/.mysql_history
    /root/mysql-5.7.30-linux-glibc2.12-x86_64.tar.gz
    /usr/lib/firewalld/services/mysql.xml
    /usr/lib/python2.7/site-packages/sos/plugins/mysql.py
    /usr/lib/python2.7/site-packages/sos/plugins/mysql.pyc
    /usr/lib/python2.7/site-packages/sos/plugins/mysql.pyo
    /usr/share/augeas/lenses/dist/mysql.aug
    /usr/share/doc/mariadb-libs-5.5.68/README.mysql-license
    /usr/share/man/man5/mysql_table.5.gz
    /usr/share/vim/vim74/syntax/mysql.vim
    
    [root@centos7 ~]#locate mysql  #无结果,说明MySQL已经彻底卸载
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
  • 相关阅读:
    小米手机抓取hci log
    JAVA实现生活废品回收系统 开源
    上门服务小程序源码 理疗,足疗,美容SAP上门服务小程序源码
    CTFshow Web入门 文件上传
    leetcode第311场周赛
    移动硬盘raw怎么办?一招教你解决RAW格式的文件
    AI模型训练参数
    桌面应用开发有哪些主流框架?
    时序预测 | Matlab实现CNN-XGBoost卷积神经网络结合极限梯度提升树时间序列预测
    皕杰报表单元格内显示方框和带√的方框和修改导出excel名称
  • 原文地址:https://blog.csdn.net/weixin_51867896/article/details/126448554