防止重装

  • yum 方式
1
2
# 查看yum是否安装过mysql
yum list installed mysql*

如或显示了列表,说明系统中有MySQL
image-20210209162826025
根据列表上的名字

1
2
3
yum remove mysql-community-client mysql-community-common mysql-community-libs mysql-community-libs-compat mysql-community-server mysql57-community-release
rm -rf /var/lib/mysql
rm /etc/my.cnf
  • rpm 查看安装
1
rpm -qa | grep -i mysql

image-20210209162927188

  • rpm 卸载
1
2
3
4
5
6
7
8
rpm -e mysql57-community-release-el7-9.noarch
rpm -e mysql-community-server-5.7.17-1.el7.x86_64
rpm -e mysql-community-libs-5.7.17-1.el7.x86_64
rpm -e mysql-community-libs-compat-5.7.17-1.el7.x86_64
rpm -e mysql-community-common-5.7.17-1.el7.x86_64
rpm -e mysql-community-client-5.7.17-1.el7.x86_64
cd /var/lib/
rm -rf mysql/

清除余项

1
2
3
4
whereis mysql
mysql: /usr/bin/mysql /usr/lib64/mysql /usr/local/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz
#删除上面的文件夹
rm -rf /usr/bin/mysql

删除配置

1
2
rm –rf /usr/my.cnf
rm -rf /root/.mysql_sercret

剩余配置检查

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

根据上面的列表,删除 ,如:mysqld