How to Reset a WordPress User Password Using WP-CLI
Prerequisites
Before proceeding, ensure:
- WP-CLI is installed and configured on your server.
- You have SSH access to the server hosting your WordPress site.
- You are not logged in as root unless absolutely necessary (use the appropriate site user account).
Step 1: Verify WP-CLI Installation
Run the following command to confirm WP-CLI is available:
wp –info
This will display version details and confirm that WP-CLI is working correctly.
Step 2: List WordPress Users
To identify the username or ID of the account you want to reset:
wp user list
This will output a table of all WordPress users with their IDs, usernames, and roles.
Step 3: Reset the Password
Use the following command to update the password for a specific user:
wp user update USERNAME_OR_ID –user_pass=”NEW_PASSWORD”
Example:
wp user update admin –user_pass=”SecurePass2024″
Important Notes
- Always use a strong, unique password (mix of uppercase, lowercase, numbers, and symbols).
- Avoid reusing old passwords.
- Do not share credentials over insecure channels.
- If you encounter errors such as “command not found” or “user not found”, double-check:
- WP-CLI installation path
- Correct WordPress root directory
- Accurate username or ID
Troubleshooting
- Command not found ? Ensure WP-CLI is installed and added to your PATH.
- User not found ? Verify the username/ID using wp user list.
- Permission denied ? Run the command with the correct user privileges (avoid root unless required).