> CentOS > CentOS入门 >

卸载Centos下自带mysql命令

1. 首先查找Mysql相关rpm

rpm -qa | grep mysql
[root@hexuweb102 ~]$ rpm -qa | grep mysql
#mysql-connector-odbc-3.51.12-2.2
#mysql-5.0.45-7.el5
#mysql-server-5.0.45-7.el5
#libdbi-dbd-mysql-0.8.1a-1.2.2

2. 开始卸载

[root@hexuweb102 ~]$ rpm -e libdbi-dbd-mysql-0.8.1a-1.2.2
[root@hexuweb102 ~]$ rpm -e mysql-server-5.0.45-7.el5
[root@hexuweb102 ~]$ rpm -e mysql-5.0.45-7.el5
#error: Failed dependencies:
#	libmysqlclient.so.15 is needed by (installed) perl-DBD-MySQL-3.0007-1.fc6.i386
#	libmysqlclient.so.15 is needed by (installed) dovecot-1.0.7-2.el5.i386
#	libmysqlclient.so.15 is needed by (installed) mysql-connector-odbc-3.51.12-2.2.i386
#	libmysqlclient.so.15(libmysqlclient_15) is needed by (installed) perl-DBD-MySQL-3.0007-1.fc6.i386
#	libmysqlclient.so.15(libmysqlclient_15) is needed by (installed) dovecot-1.0.7-2.el5.i386
#	libmysqlclient.so.15(libmysqlclient_15) is needed by (installed) mysql-connector-odbc-3.51.12-2.2.i386
#	libmysqlclient_r.so.15 is needed by (installed) MySQL-python-1.2.1-1.i386
#	libmysqlclient_r.so.15 is needed by (installed) mysql-connector-odbc-3.51.12-2.2.i386
#	libmysqlclient_r.so.15(libmysqlclient_15) is needed by (installed) MySQL-python-1.2.1-1.i386
#	libmysqlclient_r.so.15(libmysqlclient_15) is needed by (installed) mysql-connector-odbc-3.51.12-2.2.i386
#	mysql is needed by (installed) MySQL-python-1.2.1-1.i386

因为下面这些包依赖于 mysql 这个包,你删除了 mysql 其他包就可能不能用了。

解决方法:

1. 加上 –nodeps 可以卸载

rpm -e --nodeps mysql

2. 先卸载依赖

[root@hexuweb102 ~]$ rpm -e perl-DBD-MySQL-3.0007-1.fc6.i386
[root@hexuweb102 ~]$ rpm -e dovecot-1.0.7-2.el5.i386
......
......

2. 用yum删除 它会自动解决依赖

[root@hexuweb102 ~]yum remove mysql

建议还是用yum来删除或安装软件吧,包的依赖关系实在有些麻烦。

(责任编辑:IT)