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 /