All Collections
Administering Server and Website
Application Management
How to Reset WordPress User Password Using WordPress CLI
How to Reset WordPress User Password Using WordPress CLI

This KB article will instruct you on how to change the WordPress user password and update it if required.

Cloudways Product avatar
Written by Cloudways Product
Updated over a week ago

This KB article will instruct you on how to change the WordPress user password.

WP-CLI is pre-installed on all the servers deployed on Cloudways, and the steps below will demonstrate how you can operate WP-CLI and update the password.

What is WordPress CLI?

WP-CLI is a command-line interface for WordPress, and it is a set of command-line tools for managing WordPress installations on a server. It allows the WordPress admin users to carry out different administrative tasks without actually using a web browser. This management through the command-line interface enables users to take care of their WordPress websites by executing a set of defined commands. The scope of the tasks mainly includes upgrades, database backups, publishment of new posts, etc.

How to Reset User Password Using WordPress CLI

Here are a few simple steps to help you reset the user password with the help of WordPress CLI.

Step# 1

First of all, you need to connect to your server remotely via SSH so you can use WP-CLI.

If you would like to know what SSH is and why it is used, then Click Here to find out. In this example, we are using Master Credentials to access the server remotely.

You can connect to your server via SSH in two ways, so choose your preferred option from the options below. You can also click on the hyperlink text of bullet points to learn about connecting remotely to the server.

In this example, we have used an SSH client named PuTTY. After a successful connection you will see a window similar to this one:

Step# 2

Now, you need to go to the directory where your web root is located or where your wp-config.php file is located. Otherwise, WP-CLI will not work. By default, it is in the public_html directory and we will also follow the default path to operate WP-CLI in this example. Enter a command mentioned below to go into the public_html folder:

cd applications/<your_application_name>/public_html/

Important

Angle brackets are included to indicate the positions of your inputs so make sure to remove the angle brackets. Your application name is the same as your Database name (DB name). Click Here to find out where your application name is located.

After running the above command successfully you will see a similar window:

Step# 3

You may start using WP-CLI once you are in the public_html directory. Type this command to view all the users.

wp user list

Now, type this command to update the password of a user you are targeting.

wp user update <user> --user_pass=<password>

For example: wp user update john --user_pass=jqwq@@%basqwq

<user> = The user_login, user_email or ID of the user(s) to update.

Click Here if you would like to know about creating, listing, updating, and deleting the users using the WordPress CLI.

Tips

  • You can also update passwords of more than one user at a time by following this command and passing more <user> and --user_pass=<password> parameters:

wp user update <user> --user_pass=<password>, <user> --user_pass=<password>

For example: wp user update 3 --user_pass=%yest$$12998, 4 --user_pass=1$#ertq@@987

<user>= The user_login, user_email or ID of the user(s) to update.

  • You can also update your administrator password by using the same method.

That’s it! We hope this article was helpful. If you need any help, then feel free to search your query on Cloudways Support Center or contact us via chat (Need a Hand > Send us a Message). Alternatively, you can also create a support ticket.

Did this answer your question?