Tutorial

How to Reset a WordPress Admin Password Via the Command Line Using WP-CLI

Published on July 21, 2021
Default avatar

By Lyn Muldrow

Senior Developer Educator

How to Reset a WordPress Admin Password Via the Command Line Using WP-CLI

Introduction

In WordPress, oftentimes one of the most important pieces of information that is forgotten or misplaced is the admin password.

In this tutorial, learn how to retrieve or reset your WordPress admin password from the command line using WP-CLI, a tool that allows users to manage WordPress blogs from a terminal.

Prerequisites

To follow this guide, you’ll need:

Step 1 — Resetting Your WordPress Admin Password via WP-CLI

WP-CLI is a utility that allows you to perform administrative tasks via the command line. In this step, you’ll use the WP-CLI utility to reset your WordPress admin password.

After you have successfully installed WP-CLI, navigate to your main WordPress directory:

  1. cd /var/www/wordpress/

Next, you’ll grab a list of the users that are authorized to edit your WordPress site:

  1. wp user list
Output

Once the list is produced, locate the name and user ID of the admin user whose password you’d like to reset. To update the password for the user selected, enter the following, replacing the highlighted password with a secure password of your own choosing:

  1. wp user update 1 --user_pass=password

Your WordPress admin password should now be changed. In the next step, we’ll test the changes to ensure that your new admin password has been applied.

Step 2 — Testing Your WordPress Admin Password

After setting up a new admin password via WP-CLI, it’s a good idea to test the changes to be sure the password was applied correctly. To test your password, log in to the WordPress admin panel at https://yoursite.com/wp-admin, replacing the highlighted text with your website’s domain name or IP address.

If you are able to log into your WordPress dashboard, you’ve successfully changed your WordPress admin password via WP-CLI. If you’ve encountered an error, repeat Step 1 using a new password, then attempt to log in again.

Conclusion

In this tutorial, you used the WP-CLI utility to update your admin password. For more comprehensive information about WordPress, visit our list of WordPress resources.

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about us


Tutorial Series: Common WordPress Errors

This tutorial series explains how to troubleshoot and fix common errors that you may encounter when deploying, maintaining, and updating your WordPress installation.

Each tutorial in this series includes descriptions of common deployment, maintenance, or update errors, and explores ways to fix and optimize your installation to scale.

About the authors
Default avatar

Senior Developer Educator

Software engineer, writer, and speaker who loves solving problems and educating the next generation.

Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?
 
2 Comments


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Great succinct guide, thank you.

This comment has been deleted

    Try DigitalOcean for free

    Click below to sign up and get $200 of credit to try our products over 60 days!

    Sign up

    Join the Tech Talk
    Success! Thank you! Please check your email for further details.

    Please complete your information!

    Get our biweekly newsletter

    Sign up for Infrastructure as a Newsletter.

    Hollie's Hub for Good

    Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

    Become a contributor

    Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

    Welcome to the developer cloud

    DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

    Learn more
    DigitalOcean Cloud Control Panel