rpm -qa | grep mysql
# 或
yum list install | grep mysql
2、查看mysql的服务是否启动
2.1、如果启动则关闭mysql服务
systemctl stop mysqld.service # service可加可不加
# 停止MySQL的服务
[root@chenstudy ~]\# systemctl stop mysqld
# 再次查看MySQL的服务状态
[root@chenstudy ~]\# systemctl status mysqld
3、 卸载上述命令查询出的已安装程序
yum remove mysql-community-libs-8.0.30-1.el7.x86_64
rpm -qa | grep mysql
yum remove mysql-community-client-plugins-8.0.30-1.el7.x86_64
rpm -qa | grep mysql
yum remove mysql-community-server-8.0.30-1.el7.x86_64
rpm -qa | grep mysql
图一:移除mysql-community-libs-8.0.30-1.el7.x86_64
图二:查看剩余的MySQL安装包
图三:移除mysql-community-client-plugins
图四:移除mysql-community-common
图五:再次查看MySQL的安装状态
图六:移除 mysql-community-icu-data-files
图七:移除mysql80-community-release-el7-7.noarch
4、删除mysql相关文件
rm -rf /usr/lib64/mysql
rm -rf /var/lib/mysql
rm -rf /var/lib/mysql/mysql
rm -rf /etc/selinux/targeted/active/modules/100/mysql
5、删除my.cnf