論壇報錯:Table '.\Tablename\posts' is marked as crashed and should be repaired
phpMyAdmin 的 Repair 按鈕無效,需命令列深度修復。
# 進入 MySQL 安裝目錄 bin 資料夾
myisamchk -c -r ../data/tablename/posts.MYI
-c 檢查,-r 修復(重建索引)。修復完成無需重啟 MySQL 服務即可生效。
dede_archives),索引檔易損壞。錯誤代碼:145
| 級別 | 命令 | 適用場景 | 速度 |
|---|---|---|---|
| 1. 快速修復 | myisamchk --recover --quick /path/to/tbl_name | 常見索引錯誤 | 最快 |
| 2. 標準修復 | myisamchk --recover /path/to/tbl_name | 快速修復失效 | 中等 |
| 3. 安全修復 | myisamchk --safe-recover /path/to/tbl_name | 嚴重損壞、其他方法無效 | 最慢 |
cp tbl_name.MYD /backup/DELETE FROM tbl_name;(產生新空索引檔).MYD 覆蓋新空資料檔。myisamchk --recover /path/to/tbl_name(根據資料檔 + .frm 重建索引)。.MYD、.MYI。.frm, .MYD, .MYI)。CREATE TABLE 語句重建表(產生新 .frm)。.MYD/.MYI。myisamchk --silent --fast /datadir/*/*.MYImyisamchk --silent --force --fast --update-state -O key_buffer=64M -O sort_buffer=64M -O read_buffer=1M -O write_buffer=1M /datadir/*/*.MYIFLUSH TABLES 或停止 MySQL 服務,否則報錯 warning: clients are using or haven't closed the table properly。CHECK TABLE / REPAIR TABLE,避免檔案鎖衝突。