CentOS7 完全卸载yum 安装 mysql
-
检查 rpm 包
rpm -qa |grep -i mysql # 运行结果 mysql-community-libs-5.7.37-1.el7.x86_64 mysql57-community-release-el7-10.noarch mysql-community-server-5.7.37-1.el7.x86_64 mysql-community-common-5.7.37-1.el7.x86_64 mysql-community-libs-compat-5.7.37-1.el7.x86_64 mysql-community-client-5.7.37-1.el7.x86_64
-
卸载 rpm
yum remove mysql-community-libs-5.7.37-1.el7.x86_64 yum remove mysql57-community-release-el7-10.noarch yum remove mysql-community-server-5.7.37-1.el7.x86_64 yum remove mysql-community-common-5.7.37-1.el7.x86_64 yum remove mysql-community-libs-compat-5.7.37-1.el7.x86_64 yum remove mysql-community-client-5.7.37-1.el7.x86_64
-
重新检查应为空
rpm -qa |grep -i mysql
-
查找 mysql 相关目录
find / -name mysql # 运行结果 /etc/selinux/targeted/active/modules/100/mysql /etc/selinux/targeted/tmp/modules/100/mysql /var/lib/mysql /var/lib/mysql/mysql /usr/share/mysql
-
逐一删除
rm -rf /var/lib/mysql rm -rf /var/lib/mysql/mysql rm -rf /usr/share/mysql rm -rf /etc/selinux/targeted/tmp/modules/100/mysql rm -rf /etc/selinux/targeted/active/modules/100/mysql
-
删除配置文件
rm -rf /etc/my.cnf
-
删除安装日志,防止重新安装无法记录密码
rm -rf /var/log/mysqld.log