Jquery中文网 www.jquerycn.cn
Jquery中文网 >  数据库  >  mysql  >  正文 修复MySQL的MyISAM表命令check table用法

修复MySQL的MyISAM表命令check table用法

发布时间:2017-02-23   编辑:www.jquerycn.cn
jquery中文网为您提供修复MySQL的MyISAM表命令check table用法等资源,欢迎您收藏本站,我们将为您提供最新的修复MySQL的MyISAM表命令check table用法资源
MyISAM如果损坏了修复方法是比较简单了我们只要使用check table命令就可以了,下面我们来看一篇关于修复MySQL的MyISAM表命令check table用法,具体如下所示。

MySQL日志文件里出现以下错误,MySQL表通常不会发生crash情况,一般是在更新数据库时MySQL停止会导致。

CHECK TABLE语法

CHECK TABLE tbl_name[,tbl_name] ... [option] ...
option= {QUICK | FAST | MEDIUM | EXTENDED | CHANGED}

检查一个或多个表是否有错误。CHECK TABLE对MyISAM和InnoDB表有作用。对于MyISAM表,关键字统计数据被更新。

CHECK TABLE也可以检查视图是否有错误,比如在视图定义中被引用的表已不存在。
CHECK TABLE语句会返回一个含有以下列的表:

[Warning] Checking table:   './数据库名/表名'
[ERROR] mysqld: Table './数据库名/表名' is marked as crashed and should be repaired

确认错误使用「check table 表名;」命令。

<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy6207')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy6207>

mysql> check table 表名 quick;

------------------ ------- ---------- ----------------------------------------------------------
| Table | Op | Msg_type | Msg_text |
------------------ ------- ---------- ----------------------------------------------------------
| DB.表名 | check | warning | Table is marked as crashed and last repair failed |
| DB.表名 | check | warning | 1 client is using or hasn't closed the table properly |
| DB.表名| check | error | Size of datafile is: 268414976 Should be: 268871480 |
| DB.表名 | check | error | Corrupt |
------------------ ------- ---------- ----------------------------------------------------------

</td></tr></table>

从以上结果可以看出MySQL数据库出现了损坏。

修复时使用「repair table 表名;」命令,需要注意的是repair table命令只能用于MyISAM表。

<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy1655')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy1655>

mysql> repair table 表名;
--------------- -------- ---------- --------------------------------------------------------
| Table | Op | Msg_type | Msg_text |
--------------- -------- ---------- --------------------------------------------------------
| DB.表名 | repair | info | Found block that points outside data file at 268414940 |
| DB.表名 | repair | warning | Number of rows changed from 4377692 to 4370359 |
| DB.表名 | repair | status | OK |
--------------- -------- ---------- --------------------------------------------------------

</td></tr></table>

再次执行check table命令。

<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy4533')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy4533>

mysql> check table 表名 quick;
--------------- ------- ---------- ----------
| Table | Op | Msg_type | Msg_text |
--------------- ------- ---------- ----------
| DB.表名 | check | status | OK |
--------------- ------- ---------- ----------

</td></tr></table>

您可能感兴趣的文章:
修复MySQL的MyISAM表命令check table用法
mysql repair table导致数据丢失的解决方法
MySQL正确的myisam转innodb的方法
mysql报错"is marked as crashed and should be repaired"的解决方法
掉电导致mysql innodb #145 错误解决解决
mysql数据文件损坏后的修复方法
修改mysql默认存储引擎的方法
mysqlhotcopy命令备份myisam表的例子
mysql 重新建立索引的方法
MySQL ALTER命令

[关闭]