mysql 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 表名;」命令。
| ?代碼如下 | 復制代碼 |
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 | ------------------ ------- ---------- ---------------------------------------------------------- | |
從以上結果可以看出MySQL數據庫出現了損壞。
修復時使用「repair table 表名;」命令,需要注意的是repair table命令只能用于MyISAM表。
| ?代碼如下 | 復制代碼 |
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 | --------------- -------- ---------- -------------------------------------------------------- | |
再次執行check table命令。
| ?代碼如下 | 復制代碼 |
mysql> check table 表名 quick; --------------- ------- ---------- ---------- | Table | Op | Msg_type | Msg_text | --------------- ------- ---------- ---------- | DB.表名 | check | status | OK | --------------- ------- ---------- ---------- | |
總結
以上是生活随笔為你收集整理的mysql check table_修复MySQL的MyISAM表命令check table用法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Android开发从0到1学习(知识+路
- 下一篇: vs2010中文旗舰版,vs2013,v