这几天在linux上面安装mysql 来来回回搞了几次,但是确实没有安装成功很难受,但是却知道如何卸载mysql

在卸载之前我们首先检验一下mysql是否安装了

[root@izr86o15kikb3az usr]# rpm -qa | grep -i mysql
mysql-community-client-5.6.44-2.el7.x86_64
mysql-community-common-5.6.44-2.el7.x86_64
mysql-community-server-5.6.44-2.el7.x86_64
mysql-community-release-el7-5.noarch
mysql-community-devel-5.6.44-2.el7.x86_64
mysql-community-libs-5.6.44-2.el7.x86_64

这样看我确实是安装了mysql,现在我要将他们卸载掉

暂定mysql服务:service mysql stop

然后开始对上面安装的mysql进行一个一个卸载

 rpm -e --nodeps mysql-community-libs-5.6.4

卸载了之后我们重新用 ps -f | grep mysql 会发现上面的已经没了,这样就说明这个已经卸载了

我们继续将其他的都卸载

然后我们利用: find / -name mysql

[root@izr86o15kikb3az usr]# find / -name mysql
/opt/mysql
/var/lib/mysql
/var/lib/mysql/mysql
/run/lock/subsys/mysql
/etc/selinux/targeted/active/modules/100/mysql
/usr/share/mysql
[root@izr86o15kikb3az usr]# cd ..

接下来我们把所有的文件夹都删掉

[root@izr86o15kikb3az /]# rm -rf /opt/mysql
[root@izr86o15kikb3az /]# rm -rf /var/lib/mysql
[root@izr86o15kikb3az /]# rm -rf /run/lock/subsys/mysql
[root@izr86o15kikb3az /]# rm -rf /etc/selinux/targeted/active/modules/100/mysql
[root@izr86o15kikb3az /]# rm -rf /usr/share/mysql

这样就把所有的关于mysql的文件都删除了最后我们到 /etc/init.d 文件夹下面发现有mysqld,我们也把他删掉

[root@izr86o15kikb3az /]# cd etc
[root@izr86o15kikb3az etc]# cd init.d
[root@izr86o15kikb3az init.d]# vim mysqld

[1]+ Stopped vim mysqld
[root@izr86o15kikb3az init.d]# rm mysqld
rm: remove regular file ‘mysqld’? y
[root@izr86o15kikb3az init.d]# ls
aegis agentwatch functions netconsole network README
[root@izr86o15kikb3az init.d]#

然后我们可以把mysql.service删除掉

find: unknown predicate `-/'
[root@izr86o15kikb3az init.d]# find / -name mysql.service
/run/systemd/generator.late/mysql.service
[root@izr86o15kikb3az init.d]# service mysql statrt
The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.
[root@izr86o15kikb3az init.d]# cd ../..//run/systemd/generator.late/
[root@izr86o15kikb3az generator.late]# ls
aegis.service mysqld.service netconsole.service runlevel2.target.wants runlevel4.target.wants
agentwatch.service mysql.service network.service runlevel3.target.wants runlevel5.target.wants
[root@izr86o15kikb3az generator.late]# rm mysqld.service
rm: remove regular file ‘mysqld.service’? y
[root@izr86o15kikb3az generator.late]# rm mysql.service
rm: remove symbolic link ‘mysql.service’? y
[root@izr86o15kikb3az generator.late]#

 

 

希望对你有所帮助