修改 innodb_log_file_size 後啟動 MySQL 失敗,錯誤日誌顯示:
InnoDB: Error: log file ./ib_logfile0 is of different size 0 5242880 bytes
原因:磁碟上現有 Redo Log 檔案大小與配置文件新設定不一致,InnoDB 拒絕啟動以防資料損壞。
mkdir /backup/ib_log_$(date +%F)mv /var/lib/mysql/ib_logfile* /backup/ib_log_$(date +%F)/systemctl restart mysqldib_logfile0, ib_logfile1 依配置大小自動建立。innodb_log_file_size = 256M
innodb_log_files_in_group = 2
重啟後將看到兩個 268435456 bytes (256MB) 的 log 檔案。
systemctl stop mysqld),確保 Redo Log 已 Checkpoint、無未刷盤事務。datadir 後再操作。innodb_log_file_size 需同時考慮 innodb_log_files_in_group 總大小不超過 Buffer Pool 25%。切勿直接修改配置後強行啟動,必須移除舊 log 檔案。若誤刪 ibdata1 (系統表空間) 將導致資料庫不可用,需從備份恢復。