Home  >  Article  >  Database  >  快速修复损坏的MySQL数据库

快速修复损坏的MySQL数据库

WBOY
WBOYOriginal
2016-06-07 18:04:02864browse

在长时间使用 MySQL 后,数据库可能会出现一些问题。大多数问题可以通过简单的操作进行快速修复。下面介绍两种快速检修 MySQL 数据库的方法。

1、myisamchk
使用 myisamchk 必须暂时停止 MySQL 服务器。例如,我们要检修 discuz 数据库。执行以下操作:
# service mysql stop (停止 MySQL );
# myisamchk -r /数据库文件的绝对路径/*MYI
# service mysql start
myisamchk 会自动检查并修复数据表中的索引错误。
2、mysqlcheck
使用 mysqlcheck 无需停止 MySQL ,可以进行热修复。操作步骤如下:
# mysqlcheck -r discuz.*

# service mysql stop (停止 MySQL );
# myisamchk -r /数据库文件的绝对路径/*MYI
# service mysql start
myisamchk 会自动检查并修复数据表中的索引错误。

注意,无论是 myisamchk 还是 mysqlcheck ,一般情况下不要使用 -f 强制修复,-f 参数会在遇到一般修复无法成功的时候删除部分出错数据以尝试修复。所以,不到万不得已不要使用 -f。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn