Linux下干净卸载mysql详解

1.查看当前安装mysql情况

rpm -qa|grep -i mysql 

显示安装情况如下

[root@iZ23hdndo4vZ ~]# rpm -qa|grep -i mysql 
mysql-5.1.73-8.el6_8.x86_64
mysql-libs-5.1.73-8.el6_8.x86_64
mysql-devel-5.1.73-8.el6_8.x86_64
mysql-server-5.1.73-8.el6_8.x86_64
perl-DBD-MySQL-4.013-3.el6.x86_64
[root@iZ23hdndo4vZ ~]# 

2、停止mysql服务、删除之前安装的mysql

删除命令:rpm -ev –-nodeps 包名

 
[root@iZ23hdndo4vZ ~]# rpm -e –nodeps mysql-5.1.73-8.el6_8.x86_64
...

如果提示依赖包错误,则使用以下命令尝试

[root@localhost tmp]# rpm -qa | grep -i mysql
mysql-libs-5.1.73-3.el6_5.x86_64
 
[root@localhost tmp]# rpm -ev mysql-libs-5.1.73-3.el6_5.x86_64  
error: Failed dependencies:
        libmysqlclient.so.16()(64bit) is needed by (installed) postfix-2:2.6.6-6.el6_5.x86_64
        libmysqlclient.so.16(libmysqlclient_16)(64bit) is needed by (installed) postfix-2:2.6.6-6.el6_5.x86_64
        mysql-libs is needed by (installed) postfix-2:2.6.6-6.el6_5.x86_64
[root@localhost tmp]# rpm -ev mysql-libs-5.1.73-3.el6_5.x86_64   --nodeps
[root@localhost tmp]#

如果提示错误:error: %preun(xxxxxx) scriptlet failed, exit status 1

则用以下命令尝试:

rpm -e --noscripts mysql-5.1.73-8.el6_8.x86_64

3、查找之前老版本mysql的目录、并且删除老版本mysql的文件和库

[root@iZ23hdndo4vZ ~]# find / -name mysql
/usr/lib64/perl5/DBD/mysql
/usr/lib64/perl5/auto/DBD/mysql
/usr/lib64/mysql
/usr/include/mysql
/usr/share/mysql
/usr/bin/mysql
/var/lib/mysql
/var/lib/mysql/mysql
[root@iZ23hdndo4vZ ~]# 

查找目录并删除
注意:卸载后/etc/my.cnf不会删除,需要进行手工删除

4、再次查找机器是否安装mysql

rpm -qa|grep -i mysql 

注意当报包冲突时错误信息如下

Transaction check error:
  file /usr/share/mysql/charsets/README from install of MySQL-server-5.6.39-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
  file /usr/share/mysql/czech/errmsg.sys from install of MySQL-server-5.6.39-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
  file /usr/share/mysql/danish/errmsg.sys from install of MySQL-server-5.6.39-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
  file /usr/share/mysql/dutch/errmsg.sys from install of MySQL-server-5.6.39-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
  file /usr/share/mysql/english/errmsg.sys from install of MySQL-server-5.6.39-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
  file /usr/share/mysql/estonian/errmsg.sys from install of MySQL-server-5.6.39-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
  file /usr/share/mysql/french/errmsg.sys from install of MySQL-server-5.6.39-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
  file /usr/share/mysql/german/errmsg.sys from install of MySQL-server-5.6.39-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
  file /usr/share/mysql/greek/errmsg.sys from install of MySQL-server-5.6.39-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
  file /usr/share/mysql/hungarian/errmsg.sys from install of MySQL-server-5.6.39-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
  file /usr/share/mysql/italian/errmsg.sys from install of MySQL-server-5.6.39-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
  file /usr/share/mysql/japanese/errmsg.sys from install of MySQL-server-5.6.39-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
  file /usr/share/mysql/korean/errmsg.sys from install of MySQL-server-5.6.39-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
  file /usr/share/mysql/norwegian-ny/errmsg.sys from install of MySQL-server-5.6.39-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
  file /usr/share/mysql/norwegian/errmsg.sys from install of MySQL-server-5.6.39-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
  file /usr/share/mysql/polish/errmsg.sys from install of MySQL-server-5.6.39-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
  file /usr/share/mysql/portuguese/errmsg.sys from install of MySQL-server-5.6.39-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
  file /usr/share/mysql/romanian/errmsg.sys from install of MySQL-server-5.6.39-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
  file /
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值