とつぜんWordpressが動かなくなった

ブラウザは500ってなる。
Windows ServerのMySQL notifierは

Error
The service MySQL failed the most recent status change request with the message
The service mysql was not found in the Windows Services If problem persists please restart MySQL Notifier.

mysql.iniが見当たらない。。。コピーして作る。でも間違い。
Windows7+MySQL5.5のmy.ini在り処

C:\ProgramData\MySQL\MySQL Server 5.7\my.ini

あった。

サービスからMySQLを実行すると

ローカルコンピューター上のMySQLサービスは起動して停止しました。サービスの中には、ほかのサービスやプログラムで使用されていない場合は自動的に停止するものがあります。

わからん。

Fatal error: mysql.user table is damaged. Please run mysql_upgrade.

C:\ProgramData\MySQL\MySQL Server 5.7\Dataのいろいろなlogファイルを眺めるとServerName.errってのがある。
気になったのがコレ

[ERROR] Fatal error: mysql.user table is damaged. Please run mysql_upgrade.

ログインも試すができない。

c:\Program Files\MySQL\MySQL Server 5.7\bin>mysql -u root -p
Enter password: **************
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)

事態はエライこと深刻だったかもしれない

windowsのMySQLのrootのパスワード忘れた時の対処法(MySQL5.1)を参考

c:\Program Files\MySQL\MySQL Server 5.7\bin>mysqld.exe --skip-grant-tables
mysqld: Can't change dir to 'c:\Program Files\MySQL\MySQL Server 5.7\data\' (Errcode: 2 - No such file or directory)
2016-04-15T09:08:34.641250Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-04-15T09:08:34.641250Z 0 [Warning] Insecure configuration for --secure-file-priv: Current value does not restrict location of generated files. Consider setting it to a valid, non-empty path.
2016-04-15T09:08:34.641250Z 0 [Note] mysqld.exe (mysqld 5.7.11) starting as process 1728 ...
2016-04-15T09:08:34.641250Z 0 [Warning] Can't create test file c:\Program Files\MySQL\MySQL Server 5.7\data\izm-srv.lower-test
2016-04-15T09:08:34.656875Z 0 [Warning] Can't create test file c:\Program Files\MySQL\MySQL Server 5.7\data\izm-srv.lower-test
2016-04-15T09:08:34.656875Z 0 [ERROR] failed to set datadir to c:\Program Files\MySQL\MySQL Server 5.7\data\
2016-04-15T09:08:34.656875Z 0 [ERROR] Aborting

2016-04-15T09:08:34.656875Z 0 [Note] Binlog end
2016-04-15T09:08:34.656875Z 0 [Note] mysqld.exe: Shutdown complete

mysqldをコマンドで実行しているときにmy.iniを読み込んでいないぞ!ってことに気がつくのに数時間・・・

c:\Program Files\MySQL\MySQL Server 5.7\bin>mysqld.exe --defaults-file="C:\ProgramData\MySQL\MySQL Server 5.7\my.ini" --skip-grant-tables

からの〜

C:\Users\Administrator>mysql -u root mysql
mysql> update user set password=PASSWORD('your_password') where user='root' and host='localhost';
Query OK, 0 rows affected, 1 warning (0.13 sec)
Rows matched: 1 Changed: 0 Warnings: 1

全てのコマンドプロンプトを閉じてから実行したらコーなった

C:\Users\Administrator>mysql -u root -p
Enter password: ***********
ERROR 1130 (HY000): Host 'localhost' is not allowed to connect to this MySQL server

わからんのじゃー!


視点を変えてサービスのMySQLを実行させて、C:\ProgramData\MySQL\MySQL Server 5.7\Data\ServerName.errのエラーファイルを眺める

複数のエラーが出ているよ、、、順番に確認していく

TIMESTAMP with implicit DEFAULT value is deprecated.

[Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

MySQL - 5.6 系で TIMESTAMP 型デフォルト値警告!を参考

# my.iniのこのあたりに追記
[mysqld]
explicit_defaults_for_timestamp = true

でなくなった!次!!

'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode.

[Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.

警告だから無視することにしよう

次のエラー

Plugin keyring_file reported: 'keyring_file initialization failure.

[ERROR] Plugin keyring_file reported: 'keyring_file initialization failure. Please check if the keyring_file_data points to readable keyring file or keyring file can be created in the specified location. The keyring_file will stay unusable until correct path to the keyring file gets provided'

Error in MySQL v5.7.11 installation after compilingを参考
試行錯誤の結果、Windowsの記述でエラーがなくなったのがコレ

# my.iniのこのあたりに追記
[mysqld]
keyring_file_data = "C:\ProgramData\MySQL\MySQL Server 5.7\Data\keyring"

次のエラー

InnoDB: The innodb_system data file 'ibdata1' must be writable

[ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable

The innodb_system data file~でmacのmysqlが動かない場合の対処法を参考

C:\ProgramData\MySQLのプロパティ>詳細設定>所有権
AdministratorになっていたのでNETWORK SERVICEに変更する

この変更のときにタスクマネージャーにmysqldが存在していたので、「はて?動いているはず無いのに・・・死ね!」って大声で殺したら挙動が変わってしまったような・・・

次のエラー

Fatal error: mysql.user table is damaged. Please run mysql_upgrade.

ほら

[ERROR] Fatal error: mysql.user table is damaged. Please run mysql_upgrade.

またあえたね。ふぅー

c:\>mysqld.exe --defaults-file="C:\ProgramData\MySQL\MySQL Server 5.7\my.ini" --skip-grant-tables

コマンドプロンプトを開く

C:\>mysql -u root mysql

mysql> update user set password=PASSWORD('your_password') where user='root' and host='localhost';
Query OK, 0 rows affected, 1 warning (0.13 sec)
Rows matched: 1 Changed: 0 Warnings: 1

C:\ProgramData\MySQLのアクセス権にNETWORK SERVICEが無かったので追加するけど、エラーは変わらない。

とりあえず、シャットダウンしてみる

c:\>mysqladmin shutdown

困ってきたぞ

Fatal error: mysql.user table is damaged. Please run mysql_upgrade.

MySQLサービスを起動してログを眺める
MySQL5.7が起動しないトラブルを参考

[ERROR] Fatal error: mysql.user table is damaged. Please run mysql_upgrade.
[ERROR] Aborting

binの中で

mysql_safe --defaults-file="C:\ProgramData\MySQL\MySQL Server 5.7\my.ini" --skip-grant-tables --user=[root] &
'mysql_safe' は、内部コマンドまたは外部コマンド、操作可能なプログラムまたはバッチ ファイルとして認識されていません。

ならば

c:\Program Files\MySQL\MySQL Server 5.7\bin>mysql_upgrade.exe
Checking if update is needed.
Checking server version.
Running queries to upgrade MySQL server.
mysql_upgrade: (non fatal) [ERROR] 1728: Cannot load from mysql.proc. The table
is probably corrupted
Checking system database.
mysql.columns_priv OK
mysql.db OK
mysql.engine_cost OK
mysql.event OK
mysql.func OK
mysql.general_log OK
mysql.gtid_executed OK
mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
mysql.host OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
mysql.ndb_binlog_index OK
mysql.plugin OK
mysql.proc OK
mysql.procs_priv OK
mysql.proxies_priv OK
mysql.server_cost OK
mysql.servers OK
mysql.slave_master_info OK
mysql.slave_relay_log_info OK
mysql.slave_worker_info OK
mysql.slow_log OK
mysql.tables_priv OK
mysql.time_zone OK
mysql.time_zone_leap_second OK
mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
The sys schema is already up to date (version 1.5.0).
Found 0 sys functions, but expected 21. Re-installing the sys schema.
Upgrading the sys schema.
Checking databases.
sys.sys_config OK
wordpress.wp_commentmeta OK
wordpress.wp_comments OK
wordpress.wp_links OK
wordpress.wp_options OK
wordpress.wp_postmeta OK
wordpress.wp_posts OK
wordpress.wp_term_relationships OK
wordpress.wp_term_taxonomy OK
wordpress.wp_termmeta OK
wordpress.wp_terms OK
wordpress.wp_uam_accessgroup_to_object OK
wordpress.wp_uam_accessgroups OK
wordpress.wp_usermeta OK
wordpress.wp_users OK
Upgrade process completed successfully.
Checking if update is needed.


・・・なにかやっても、振り出しに戻ることばかりなので、バックアップを取ってMySQLの再インストールを行うことにします。