How to reset WordPress user password using WP-CLI

October 7, 2024 / WordPress

WP-CLI allows you to manage WordPress sites directly from the command line, making it especially useful when you cannot access the WordPress admin dashboard or are managing multiple installations.

Steps to Reset a WordPress User Password via WP-CLI:

  1. Log in to your server via SSH as the user that owns the WordPress files.
  2. Navigate to the WordPress installation directory using the cd command.
  3. Verify that WP-CLI is working by running:
    wp --info
  4. List all WordPress users to identify the correct username or user ID:
    wp user list
  5. Reset the password using the username or user ID:
    wp user update USERNAME_OR_ID --user_pass="NEW_PASSWORD"
  6. Once the command runs successfully, WP-CLI will confirm that the user record has been updated.
  7. Log in to the WordPress admin panel using the newly set password.
    Example Command

    wp user update admin --user_pass="SecurePass2024"

    This command resets the password for the admin user.

When to Use WP-CLI for Password Reset?

  • When access to the WordPress dashboard is unavailable.
  • When resetting passwords on multiple WordPress sites.
  • When performing server-level WordPress management tasks.

Using WP-CLI ensures a faster and more reliable password reset without relying on email recovery or database edits.

If you require assistance while using WP-CLI, feel free to contact our support team.

Spread the love