一、检查服务器是否已经安装了MySQL
rpm -qa|grep mysql
如下所示
mysql-community-libs-compat-8.1.0-1.el7.x86_64
mysql-community-server-8.1.0-1.el7.x86_64
mysql-community-icu-data-files-8.1.0-1.el7.x86_64
mysql-community-common-8.1.0-1.el7.x86_64
php-mysqlnd-7.3.33-1.el7.remi.x86_64
mysql-community-libs-8.1.0-1.el7.x86_64
mysql-community-client-plugins-8.1.0-1.el7.x86_64
mysql-community-client-8.1.0-1.el7.x86_64
二、查看MySQL服务是否开启
systemctl status mysqld
如下所示:
mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2024-02-20 15:24:50 CST; 9s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 30152 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 30194 (mysqld)
Status: "Server is operational"
Tasks: 38
CGroup: /system.slice/mysqld.service
└─30194 /usr/sbin/mysqld
Feb 20 15:24:45 i2MaskingCtrl systemd[1]: Starting MySQL Server...
Feb 20 15:24:50 i2MaskingCtrl systemd[1]: Started MySQL Server.
如开启则关闭MySQL服务,执行以下命令:
systemctl stop mysqld
三、查找含有MySQL的目录
find / -name mysql
如下所示:
/etc/logrotate.d/mysql
/var/lib/mysql
/var/lib/mysql/mysql
/usr/bin/mysql
/usr/lib64/mysql
根据自己查找出来的目录进行依次删除:
rm -rf /etc/logrotate.d/mysql /var/lib/mysql /var/lib/mysql/mysql /usr/bin/mysql /usr/lib64/mysql
还需删除以下两个目录:文章来源:https://www.toymoban.com/news/detail-834181.html
//mysql的配置文件
rm -rf /etc/my.cnf
//如果不删除这个文件,则重新安装的Mysql将无法设置password
rm -rf /var/log/mysqld.log
四、查找MySQL安装的组件服务
rpm -qa|grep -i mysql
如下所示:
mysql-community-libs-compat-8.1.0-1.el7.x86_64
mysql-community-server-8.1.0-1.el7.x86_64
mysql-community-icu-data-files-8.1.0-1.el7.x86_64
mysql-community-common-8.1.0-1.el7.x86_64
php-mysqlnd-7.3.33-1.el7.remi.x86_64
mysql-community-libs-8.1.0-1.el7.x86_64
mysql-community-client-plugins-8.1.0-1.el7.x86_64
mysql-community-client-8.1.0-1.el7.x86_64
卸载并删除查找出来的组件服务:文章来源地址https://www.toymoban.com/news/detail-834181.html
rpm -ev mysql-community-libs-compat-8.1.0-1.el7.x86_64
rpm -ev mysql-community-server-8.1.0-1.el7.x86_64
rpm -ev mysql-community-icu-data-files-8.1.0-1.el7.x86_64
rpm -ev mysql-community-common-8.1.0-1.el7.x86_64
rpm -ev mysql-community-libs-8.1.0-1.el7.x86_64
rpm -ev mysql-community-client-plugins-8.1.0-1.el7.x86_64
rpm -ev mysql-community-client-8.1.0-1.el7.x86_64
注:如果删除不了则加上--nodeps。例如:rpm -ev --nodeps mysql-community-libs-compat-8.1.0-1.el7.x86_64
五、卸载完成后检查是否卸载成功
rpm -qa|grep -i mysql
php-mysqlnd-7.3.33-1.el7.remi.x86_64
systemctl start mysql
如报错Failed to start mysql.service: Unit not found.
则说明此时mysql已经卸载干净了。
到了这里,关于Linux下彻底卸载MySQL数据库的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!