Home > Database > Mysql Tutorial > body text

MySQL修复myisam表

WBOY
Release: 2016-06-07 17:01:57
Original
1124 people have browsed it

开始还是用phpmyadmin去修复,结果不管用!然后使用mysql自带的myisamchk,操作如下:找到出错表所在位置(linux下mysql数据通常保存

来个实例最实际:

今天发现网站数据有点异常,马上检查一下数据库,,操作某张表(tbl_test)的时候出现如下错误:

Table ‘.\mydb\tbl_test’ is marked as crashed and should be repaired

开始还是用phpmyadmin去修复,结果不管用!

然后使用mysql自带的myisamchk,操作如下:

找到出错表所在位置(linux下mysql数据通常保存在/var/lib/mysql/下)

shell>cd /var/lib/mysql/mydb;

shell>myisamchk -r q tbl_test; (快速修复模式,会自动检查索引表和数据表是否能够一致,如果一致,则可以修复)

如果上一步失败,执行下一步

shell>myisamchk -r tbl_test;(会删除不一致的数据和索引,并重新构建索引)

如果再失败,执行下一步

shell>myisamchk --safe-recover tbl_test;

注意:使用myisamchk前,要确保mysqld没有在访问要检查的表。最好停止mysqld。

linux

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template