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

MySQL 從 MyISAM 遷移至 InnoDB 完整避坑實錄

     編輯:MySQL 資料庫相關知識

現象:啟用 InnoDB 後服務啟動失敗

原配置 Non-Transactional Database Only(僅 MyISAM),安裝 WordPress 後頻繁出現 mysqld-nt.exe 應用程式錯誤 0x005346c4 記憶體不可讀,服務自動停止。

錯誤日誌是關鍵

查看 Data/主機名.err 發現核心錯誤:

InnoDB: Error: log file .\ib_logfile0 is of different size 0 52428800 bytes
InnoDB: than specified in the .cnf file 0 10485760 bytes!
[ERROR] Default storage engine (InnoDB) is not available

原因:配置檔 innodb_log_file_size 與現有日誌檔大小不一致。

分步解決流程

  1. 停止服務,備份 my.ini。
  2. 刪除舊日誌檔:ib_logfile0、ib_logfile1(Data 目錄下)。
  3. 重啟服務,InnoDB 會依配置重建日誌檔。若仍報 ib_logfile1 size mismatch,再刪一次並重啟作業系統(Windows 鎖定檔案機制需重開機釋放)。
  4. 若出現 No valid checkpoint found,連同 ibdata* 系統表空間檔一併刪除(資料會全失,需先備份),重啟讓 InnoDB 從頭初始化。

成功啟動標誌

InnoDB: Started; log sequence number 0 0
mysqld-nt: ready for connections. Version: '5.0.18-nt' port: 3306

遷移建議

  • 生產環境嚴禁直接刪 ibdata*,應使用 mysqldump 導出 → 修改建表引擎為 InnoDB → 匯入新實例。
  • 配置 innodb_file_per_table=ON 獨立表空間,便於後續管理。
  • 調整 innodb_buffer_pool_size 至實體記憶體 60%-70%。
  • 啟用 innodb_flush_log_at_trx_commit=1 保證 ACID。
  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved