How to reset WordPress user password using WP-CLI

October 7, 2024 / WordPress

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:

  1. Connect to your server via SSH using a terminal or command prompt.
  2. Navigate to the directory in which WordPress is installed.
    For example:
    cd /path/to/your/wordpress/installation
  3. List the WordPress users:
    1. To identify the correct username, list all the WordPress users using the following command:
      wp user list
    2. This will display a list of users along with their user IDs, usernames, and email addresses.
  4. Reset the User Password:
    1. 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>
    2. Replace <username_or_user_id> with the actual username or user ID, and <new_password> with the desired new password.
    3. Example:
      wp user update 1 --user_pass=NewPassword123
  5. Confirm the password reset:
    After running the command, you should see a confirmation message indicating that the password has been successfully updated.
  6. 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!

Spread the love