0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Wordpress ユーザーのパスワード忘れた時の対処方法

Last updated at Posted at 2025-04-15

Wordpress ユーザーのパスワードを忘れてしまったが
メール設定は行っていない場合の対処方法の備忘録です。

なお、今回の検証環境は LAMP で Worpdpress が動いている場合とします。

1. MySQLにログインする

まずは MySQL にログインしましょう

//root に昇格
$ sudo su -

//mysql に root でログイン
$ mysql -u root -p
Enter password: <パスワードを入力>

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 8.0.28-0ubuntu0.20.04.3 MySQL Community Server - GPL

Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

2. データベースを確認

-- DB一覧確認
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| wordpress_db       |
+--------------------+
5 rows in set (0.00 sec)

-- Wordpress用のDBを選択
mysql> use wordpress_db;
Database changed

-- DB内のテーブル一覧を確認
mysql> show tables;
+------------------------+
| wp_comments            |
| wp_commentmeta         |
| wp_links               |
| wp_options             |
| wp_postmeta            |
| wp_posts               |
| wp_term_relationships  |
| wp_term_taxonomy       |
| wp_terms               |
| wp_usermeta            |
| wp_users               |
+------------------------+
11 rows in set (0.00 sec)

3. 特定の Wordpress ユーザーのパスワードを更新

-- wp_users テーブル内のカラムを確認
mysql> 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              | $P$B9F5Y0lq/SLdPBz... | admin                     | admin@example.com   |                     | 2024-01-01 00:00 |                     |           0 | Admin               |
|  2 | subscriber         | $P$B9F5Y0lq/SLdPBz... | subscriber                | subscriber@example.com |                   | 2024-02-15 14:23 |                     |           0 | Subscriber          |
+----+--------------------+---------------------+---------------------------+---------------------+---------------------+-----------------+---------------------+-------------+---------------------+
2 rows in set (0.00 sec)

user_pass の部分は MD5 で暗号化されているので実際のパスワードは分からないようになっています。
今回は admin ユーザーのパスワードを変更して行きます。

-- パスワードを変更する
mysql> UPDATE wp_users SET user_pass = MD5('NewSecurePassword123!') WHERE user_login = 'admin';
Query OK, 1 row affected (0.01 sec)

例:UPDATE テーブル名 SET user_pass = MD5('任意のパスワード') WHERE user_login = 'ユーザー名';

今回の場合ですと
wp_users = テーブル名
NewSecurePassword123 = 新しパスワード
admin = ユーザー名
になります。

Query OKになれば更新完了です。
これで admin ユーザーで新規のパスワードでログイン出来るようになりました。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?