戻る

WordPress - MySQL データベースの修復

2023/09/20

WordPressアイコン


他の関連ページ
WordPress
WordPress - 再導入後①
WordPress - 再導入後➁
WordPress - Lightning



概要

注意はしていてもXAMPPでMySQLを正しく終了せずにpcをシャットダウンしてしまうことがある。

たまに、XAMPPコントロールパネルにError: MySQL shutdown unexpectedlyと表示され始動できなくなる。

エラーログによると[ERROR] mysqld.exe: Table '.\mysql\db' is marked as crashed and should be repairedとある。

検索すると「CHECK TABLE tbl_name」と入力し、エラーが表示されたら「REPAIR TABLE tbl_name」と入力する、とあったが手順が不明で入力エラーになった。他の方法を探した。

以下、MySQL全体の修復作業を記述しておく。

*(画像を拡大するには写真上で右クリックしブラウザの「新しいタブで画像を開く」を選んでそちらのタブを表示)


テスト環境 : HP製pc , Core i7-1255U, Windows 11, メモリ16GB , ストレージ SSD 512GB


*error log


2023-09-19 15:20:28 0 [ERROR] mysqld.exe: Table '.\mysql\db' is marked as crashed and should be repaired
2023-09-19 15:20:28 0 [Warning] Recovering table: '.\mysql\db'
2023-09-19 15:20:28 0 [Note] mysql.db: Wrong CRC on datapage at 1
2023-09-19 15:20:28 0 [Note] mysql.db: Wrong CRC on datapage at 2
2023-09-19 15:20:28 0 [Note] mysql.db: Wrong CRC on datapage at 3
2023-09-19 15:20:28 0 [ERROR] mysql.db: Rows lost (Found 0 of 3); Aborting because safe repair was requested
2023-09-19 15:20:28 0 [ERROR] Couldn't repair table: mysql.db
2023-09-19 15:20:28 0 [ERROR] Fatal error: Can't open and lock privilege tables: Index for table 'db' is corrupt; try to repair it
2023-09-19 15:20:28 0 [ERROR] Aborting
2023-09-19 15:20:29 0 [ERROR] InnoDB: Operating system error number 6 in a file operation.
2023-09-19 15:20:29 0 [ERROR] InnoDB: File (unknown): 'close' returned OS error 206. Cannot continue operation
230919 15:20:29 [ERROR] mysqld got exception 0x80000003 ;


データベース修復手順



MariaDB(MySQL)のパスワードを設定


wp-config.php

修復作業で、必要になるファイルについて WordPress サポート・wp-config.php の編集



mysql.dbの修復



感想

XAMPP環境でのMySQLの修復に言及しているページは結構多く今回はダメ元で、MySQLの修復を試みて成功。


戻る