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:

  • cd /var/www/wordpress/

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

  • 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:

  • 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.

Originally posted on DigitalOcean Community Tutorials
Author: Lyn Muldrow

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *