MySQL Table doesn』t exist in engine 解決方法
- 2019 年 10 月 6 日
- 筆記
數據表設置了外鍵,在phpMyAdmin中顯示該表使用中,點擊訪問表時提示Table doesn』t exist in engine。 mysql日誌顯示:
2019-08-24 14:32:25 616 [Warning] InnoDB: Load table 『xxx』 failed, the table has missing foreign key indexes. Turn off 『foreign_key_checks』 and try again. 2019-08-24 14:32:25 616 [Warning] InnoDB: Cannot open table xxx from the internal data dictionary of InnoDB though the .frm file for the table exists. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting.html for how you can resolve the problem.
判斷為外鍵出錯所致,執行下述SQL語句關閉外鍵檢查即可進入該表:
SET FOREIGN_KEY_CHECKS = 0; //或者 SET GLOBAL FOREIGN_KEY_CHECKS = 0;
重新調整外鍵,並把外鍵檢查重新開啟即可。
SET FOREIGN_KEY_CHECK = 1; //或者 SET GLOBAL FOREIGN_KEY_CHECKS = 1;
另外有時候刪除與出問題的表沒有關聯的資料庫時,好像也有幾率出現此問題,通過上述關閉、打開外鍵檢查就可以恢復,而無需調整任何外鍵的設置,可能是InnoDB的bug。