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.
To follow this guide, you’ll need:
sudo privileges. You can follow one of our initial server setup guides to set this up.
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:
- cd /var/www/wordpress/
Next, you’ll grab a list of the users that are authorized to edit your WordPress site:
- wp user list
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:
- 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.
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.
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.
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.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.