斷電後 phpMyAdmin 顯示表「使用中」,查詢報錯:
#145 - Table './shbc/user_order_logs' is marked as crashed and should be repaired
mysql> CHECK TABLE user_order_logs;
+----------------------+-------+----------+---------------------------------------------------------+
| Table | Op | Msg_type | Msg_text |
+----------------------+-------+----------+---------------------------------------------------------+
| shbc.user_order_logs | check | warning | Table is marked as crashed |
| shbc.user_order_logs | check | error | Size of datafile is: 1368064 Should be: 1368188 |
| shbc.user_order_logs | check | error | Corrupt |
+----------------------+-------+----------+---------------------------------------------------------+
mysql> REPAIR TABLE user_order_logs;
+----------------------+--------+----------+------------------------------------------------------+
| Table | Op | Msg_type | Msg_text |
+----------------------+--------+----------+------------------------------------------------------+
| shbc.user_order_logs | repair | info | Found block that points outside data file at 1368024 |
| shbc.user_order_logs | repair | status | OK |
+----------------------+--------+----------+------------------------------------------------------+
SELECT * FROM user_order_logs LIMIT 1; 正常返回即修復成功。
REPAIR TABLE 僅支援 MyISAM、ARCHIVE、CSV 引擎。innodb_force_recovery 導出數據重建。innodb_flush_log_at_trx_commit=1 + sync_binlog=1 保證持久性。Innodb_buffer_pool_pages_dirty、Innodb_log_waits 等指標。