How to Reset a WordPress Admin Password Using WP-CLI
WP-CLI is a command-line utility that allows you to perform administrative tasks. In this post, I’ll show you how to change your WordPress admin password using the WP-CLI tool.
Step 1: List the WordPress users
To view a list of the users created under your WordPress site, run the command below from the directory where WordPress was installed.
wp user list
Here is the output:
]$ wp user list
+----+----------------+----------------+------------------------+---------------------+---------------+
| ID | user_login | display_name | user_email | user_registered | roles |
+----+----------------+----------------+------------------------+---------------------+---------------+
| 1 | testuser1 | user2 | test2@example.com | 2022-12-16 20:40:56 | administrator |
| 2 | testuser2 | user3 | test3@example.com | 2022-10-07 17:02:56 | subscriber |
+----+----------------+----------------+------------------------+---------------------+---------------+
Step 2:
Once the list has been generated, find the name and user ID of the admin user whose password you want to reset. Run the following command to change the user’s password.
wp user update ID --user_pass=password
Replace the ID and password using your user’s ID and new password.
For eg,
wp user update 1 --user_pass=UuTCrf0BtuRY
Here is the output:
]$ wp user update 1 --user_pass=UuTCrf0BtuRY
Success: Updated User 1
That’s it 🙂