How to Reset a WordPress Admin Password Using WP-CLI

If you found this post helpful, kindly share it and show your support :)

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 🙂

Loading

Mohammed Noufal

I'm Mohammed Noufal, working as Server Admin for the last 10 years.  In my day-to-day life, l had to face different problems related to Web-hosting. On my website Errorlogz.com, you can find solutions for different Web-hosting-related problems. Sometimes, I spent hours searching/googling to find a solution. This inspired me to start a website that gives solutions to different Webhosting problems. This website includes basic Linux and windows commands, and different control panels like cPanel, Plesk, DirectAdmin, Webmin & so on. You can find solutions and or suggestions for different Web-hosting related problems from here. Hence I would like to say Errorlogz is your server protector.  I will be glad if Logdetect can help any one of the Server admins to find a solution to his problem.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *