如何卸载并删除所有 MySQL 文件?

如何卸载并删除所有 MySQL 文件?

yum remove msyql在 CenOS 上使用它删除了它,它确实删除了 MySQL,但数据文件 ibdata 和配置文件 (my.cnf) 仍然存在。我该如何删除与 MySQL 相关的所有文件并重新开始。

谢谢

答案1

默认情况下,yum将使用扩展名重命名配置文件.rpmsave。如果您确实要删除与 mysql 相关的包和配置文件,请尝试以下操作:

# rpm -qa | grep mysql | \
while read p; do \
    for f in $(rpm -q --configfiles $p); do \
        rm -f $file; 
    done; \
    rpm -e $p; \
done

关于数据目录,我也建议重命名它而不是删除它:

# rm -fr /path/to/datadir/*

答案2

您可以使用 rpm 查看包中包含的所有文件


[root@server ~]# rpm -ql mysql-server
/etc/rc.d/init.d/mysqld
/usr/bin/innochecksum
/usr/bin/myisam_ftdump
/usr/bin/myisamchk
/usr/bin/myisamlog
/usr/bin/myisampack
/usr/bin/mysql_convert_table_format
/usr/bin/mysql_fix_extensions
/usr/bin/mysql_fix_privilege_tables
/usr/bin/mysql_install_db
/usr/bin/mysql_secure_installation
/usr/bin/mysql_setpermission
/usr/bin/mysql_tzinfo_to_sql
/usr/bin/mysql_upgrade
/usr/bin/mysql_zap
/usr/bin/mysqlbug
/usr/bin/mysqld_multi
/usr/bin/mysqld_safe
/usr/bin/mysqldumpslow
/usr/bin/mysqlhotcopy
/usr/bin/mysqltest
/usr/bin/perror
/usr/bin/replace
/usr/bin/resolve_stack_dump
/usr/bin/resolveip
/usr/lib64/mysql/plugin
/usr/lib64/mysql/plugin/ha_innodb_plugin.so
/usr/lib64/mysql/plugin/ha_innodb_plugin.so.0
/usr/lib64/mysql/plugin/ha_innodb_plugin.so.0.0.0
/usr/libexec/mysqld
/usr/libexec/mysqlmanager
/usr/share/doc/mysql-server-5.1.50
/usr/share/doc/mysql-server-5.1.50/my-huge.cnf
/usr/share/doc/mysql-server-5.1.50/my-innodb-heavy-4G.cnf
/usr/share/doc/mysql-server-5.1.50/my-large.cnf
/usr/share/doc/mysql-server-5.1.50/my-medium.cnf
/usr/share/doc/mysql-server-5.1.50/my-small.cnf
/usr/share/man/man1/innochecksum.1.gz
/usr/share/man/man1/msql2mysql.1.gz
/usr/share/man/man1/myisam_ftdump.1.gz
/usr/share/man/man1/myisamchk.1.gz
/usr/share/man/man1/myisamlog.1.gz
/usr/share/man/man1/myisampack.1.gz
/usr/share/man/man1/mysql.server.1.gz
/usr/share/man/man1/mysql_convert_table_format.1.gz
/usr/share/man/man1/mysql_fix_extensions.1.gz
/usr/share/man/man1/mysql_fix_privilege_tables.1.gz
/usr/share/man/man1/mysql_install_db.1.gz
/usr/share/man/man1/mysql_secure_installation.1.gz
/usr/share/man/man1/mysql_setpermission.1.gz
/usr/share/man/man1/mysql_tzinfo_to_sql.1.gz
/usr/share/man/man1/mysql_upgrade.1.gz
/usr/share/man/man1/mysql_zap.1.gz
/usr/share/man/man1/mysqlbinlog.1.gz
/usr/share/man/man1/mysqlbug.1.gz
/usr/share/man/man1/mysqlcheck.1.gz
/usr/share/man/man1/mysqld_multi.1.gz
/usr/share/man/man1/mysqld_safe.1.gz
/usr/share/man/man1/mysqldumpslow.1.gz
/usr/share/man/man1/mysqlhotcopy.1.gz
/usr/share/man/man1/mysqlimport.1.gz
/usr/share/man/man1/mysqlman.1.gz
/usr/share/man/man1/mysqltest.1.gz
/usr/share/man/man1/perror.1.gz
/usr/share/man/man1/replace.1.gz
/usr/share/man/man1/resolve_stack_dump.1.gz
/usr/share/man/man1/resolveip.1.gz
/usr/share/man/man8/mysqld.8.gz
/usr/share/man/man8/mysqlmanager.8.gz
/usr/share/mysql/config.huge.ini
/usr/share/mysql/config.medium.ini
/usr/share/mysql/config.small.ini
/usr/share/mysql/errmsg.txt
/usr/share/mysql/fill_help_tables.sql
/usr/share/mysql/my-huge.cnf
/usr/share/mysql/my-innodb-heavy-4G.cnf
/usr/share/mysql/my-large.cnf
/usr/share/mysql/my-medium.cnf
/usr/share/mysql/my-small.cnf
/usr/share/mysql/mysql_fix_privilege_tables.sql
/usr/share/mysql/mysql_system_tables.sql
/usr/share/mysql/mysql_system_tables_data.sql
/usr/share/mysql/mysql_test_data_timezone.sql
/var/lib/mysql
/var/log/mysqld.log
/var/run/mysqld

然后,您可以手动删除这些文件,或者编写脚本来检查并删除它们。

相关内容