首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫

MySQL 錯誤「Cannot find or open table ... from the internal data dictionary」殘留 .frm 文件導致

     編輯:MySQL 資料庫相關知識

錯誤日誌

Cannot find or open table phpwind/pw_zhuanti from the internal data dictionary of InnoDB though the .frm file for the table exists.
Maybe you have deleted and recreated InnoDB data files but have forgotten to delete the corresponding .frm files of InnoDB tables,
or you have moved .frm files to another database?

根因

表已被刪除 (或 InnoDB 系統表空間重建),但數據目錄下殘留 .frm 結構文件,InnoDB 內部數據字典找不到對應表對象,啟動/查詢時拋錯。

解決

  1. 定位數據目錄 (參考 datadir 參數,如 /var/lib/mysql/phpwind/)
  2. 刪除殘留文件:rm -f pw_zhuanti.frm
  3. 重啟 MySQL 或 FLUSH TABLES,錯誤消失

預防

  • 使用 DROP TABLE 而非手動刪文件
  • 遷移/重建表空間後,檢查並清理孤兒 .frm
  • MySQL 8.0 已移除 .frm,數據字典集中存儲於 mysql.ibd,此類問題不再發生
  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved