🛠 XAMPP MySQL起動エラー「MySQL shutdown unexpectedly」の対処法

🔴 エラーメッセージの例


5:57:28  [mysql] 	Error: MySQL shutdown unexpectedly.
5:57:28  [mysql] 	This may be due to a blocked port, missing dependencies, 
5:57:28  [mysql] 	improper privileges, a crash, or a shutdown by another method.
5:57:28  [mysql] 	Press the Logs button to view error logs and check
5:57:28  [mysql] 	the Windows Event Viewer for more clues
5:57:28  [mysql] 	If you need more help, copy and post this
5:57:28  [mysql] 	entire log window on the forums
  

【原因】

XAMPPのコントロールパネルでMySQLを 「Stop」せずにWindowsをシャットダウンした場合、 MySQLが正しく終了せず、内部ファイルが破損してエラーが起こることがあります。

【復旧手順】

  1. XAMPPを起動
    コントロールパネルを開きます。
  2. XAMPPのインストールフォルダを開く
    「Explorer」ボタン(「Quit」ボタンの3つ上)をクリック。
  3. mysql/data フォルダをバックアップ
    フォルダをデスクトップなどにコピーして保存。
  4. data フォルダ内のファイルをすべて削除
  5. mysql/backup フォルダの中身をコピー
    中身すべてを data フォルダへ貼り付け。
  6. バックアップから ibdata1 を戻す
    コピーしておいた data フォルダから ibdata1 をコピーし、上書き。
  7. バックアップからデータベースフォルダを戻す
    復元したいデータベース名のフォルダを data に戻す。
  8. MySQLを起動
    XAMPPコントロールパネルからMySQLを起動。
  9. phpMyAdminで確認
    「Admin」ボタンからphpMyAdminを開き、データベースが復元されているか確認。

✅ 注意点