Wordpressにログインできなくなった
Wordpressを運用していて管理者でログインできなくなってしまい焦りました。
パスワードリセットもうまく効かずmariadbを直接操作してパスワードを変更することにします。
KUSANAGI RoDのmairadbのパスワード
Kusanagi Rod上で構築している場合、mariadbのパスワードは.kusanagi.mysql
に記載されています。
.kusanagi.mysql
MYSQL_ROOT_PASSWORD=wp_root_password <-- これです!
MYSQL_DATABASE=wp_database
MYSQL_USER=wp_username
MYSQL_PASSWORD=wp_password
MYSQL_CHARSET=utf8mb4
# MYSQL_ALLOW_EMPTY_PASSWORD=
# MYSQL_RANDOM_ROOT_PASSWORD=
# SOCKET=
# MYSQL_INITDB_SKIP_TZINFO=
# MYSQL_ROOT_HOST=
Dockerコンテナのmariadbにログインする
dockerコマンドでDockerのmariadbにログインしてからWordpressのパスワードを変更します。
データベース内ではパスワードはMD5でハッシュ化されていますのでMD5コマンドを使って変更しておきます。
$ docker-compose exec db mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.5.6-MariaDB-1:10.5.6+maria~focal mariadb.org binary distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
MariaDB [(none)]> use wp_database;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [wp_database]>
MariaDB [wp_database]> select * from wp_users;
+----+------------+-----------+---------------+--------------+----------------------+---------------------+-----------------------------------------------+-------------+--------------+
| ID | user_login | user_pass | user_nicename | user_email | user_url | user_registered | user_activation_key | user_status | display_name |
+----+------------+-----------+---------------+--------------+----------------------+---------------------+-----------------------------------------------+-------------+--------------+
| 1 | admin | md5_password | admin | mail@ddress | http://example.com | 2020-08-05 05:53:54 | ???? | 0 | admin |
| 2 | user | md5_password | user | mail@ddress | | 2020-08-05 06:30:29 | ???? | 0 | ???? |
+----+------------+-----------+---------------+--------------+----------------------+---------------------+-----------------------------------------------+-------------+--------------+
2 rows in set (0.023 sec)
MariaDB [wp_database]>
MariaDB [wp_database]> update wp_users set user_pass=MD5('newpassword') where id=1;
Query OK, 1 row affected (0.034 sec)
Rows matched: 1 Changed: 1 Warnings: 0
これでWordpressにログインできるようになっていればOKです。