If you need to reset a WordPress user password, WP-CLI provides a fast and efficient way to do this from the command line. WP-CLI is a command-line interface that allows you to manage WordPress installations without using a browser.
Here is how to reset a WordPress user password using WP-CLI:
- Connect to your server via SSH using a terminal or command prompt.
- Navigate to the directory in which WordPress is installed.
For example:
cd /path/to/your/wordpress/installation - List the WordPress users:
- To identify the correct username, list all the WordPress users using the following command:
wp user list
- This will display a list of users along with their user IDs, usernames, and email addresses.
- To identify the correct username, list all the WordPress users using the following command:
- Reset the User Password:
- Once you know the username or user ID of the account, run the following command to reset the password:
wp user update <username_or_user_id> --user_pass=<new_password>
- Replace <username_or_user_id> with the actual username or user ID, and <new_password> with the desired new password.
- Example:
wp user update 1 --user_pass=NewPassword123
- Once you know the username or user ID of the account, run the following command to reset the password:
- Confirm the password reset:
After running the command, you should see a confirmation message indicating that the password has been successfully updated. - Log In with the New Password:
Now, you can log into the WordPress dashboard using the updated password.
Example:
wp user update admin --user_pass=SecurePass2024
This command will reset the password of the WordPress user admin to SecurePass2024.
Additional Tip: If you do not remember the username or need help identifying users, using the wp user list command is handy for viewing all users in the system.
By using WP-CLI, you save time and effort compared to using the WordPress dashboard, especially if you are managing multiple sites.
That is it!