斷電,導致innodb部分表壞了,phpmyadmin中看到該表顯示為使用中,並報了,#145 - Table './shbc/user_order_logs' is marked as crashed and should be repaired。
以前也解決過一次myisam表損壞,請參考:Incorrect key file for table mysql表損壞的修複方法
解決辦法如下:
mysql> select * from user_order_logs;
ERROR 145 (HY000): 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 |
+----------------------+-------+----------+---------------------------------------------------------+
3 rows in set (0.01 sec)
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 |
+----------------------+--------+----------+------------------------------------------------------+
2 rows in set (0.17 sec)
當然如果不知道使用命令可以安裝一個phpmyadmin 然後進行修複
我們在phpmyadmin中,勾選要進行最佳化操作的資料庫表,在複選框中選擇:修複表,就完成了資料表的最佳化。如下圖在視窗最下方即列表下方,有一個下拉式菜單,在其中選擇Repair Table(修複表)