How to Reset WordPress Password with WP-CLI

exist WordPress In addition to manually resetting your password through the database, did you know that you can reset your password through the WP-CLI to easily reset your password? This is actually a very handy feature, especially if you don't have a graphical interface or direct access to the backend, using a command line tool to manage WordPress becomes very efficient.

Image [1]-Easy Guide to Reset WordPress Password with WP-CLI

What is WP-CLI?

WP-CLI is a command line tool for managing WordPress. with WP-CLI, it is possible to perform updates, modify configurations and make other changes, avoiding the use of a browser.

So, is it more complicated to use? Yes, using WP-CLI requires knowledge of what the commands do. But on the other hand, using WP-CLI is much easier because you only need one command to perform the whole process. For example, when installing a plugin through a browser, you need to go to the backend admin interface, open the plugin page, search for the plugin, and then click Install. With WP-CLI, you only need one command to install the plugin.

How to reset WordPress password using WP-CLI?

Before using WP-CLI to reset passwords, first install WP-CLI on the server, as it is not pre-installed by default.

1. Installing WP-CLI on Linux

The first step is to download wp-cli.phar to the server, either using the wget or curl command. Make sure wget or curl is installed on the server.

Download command:

curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

Once the download is complete, check that the file works:

php wp-cli.phar --info

If successfully executed, you will see a similar message:

OS: Linux 4.10.0-42-generic #46~16.04.1-Ubuntu SMP Fri Sep 16 14:08:19 EDT 2022 x86_64
Shell: /usr/bin/zsh
PHP binary: /usr/bin/php
PHP version: 7.4.33
php.ini used: /etc/php/7.1/cli/php.ini
MySQL binary: /bin/mysql
MySQL version: mysql Ver 15.1 Distrib 10.6.13-MariaDB
WP-CLI root dir: /home/wp-cli/.wp-cli
WP-CLI packages dir: /home/wp-cli/.wp-cli/packages/
WP-CLI global config: /home/wp-cli/.wp-cli/config.yml
WP-CLI project config: /home/wp-cli/.wp-cli/config.yml
WP-CLI version: 1.5.0

At this point, WP-CLI has been successfully installed. However, for your convenience, you need to set wp-cli.phar as an executable file and move it to your system's PATH directory so that you can use it directly. wp Command.

chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp

Now, it is possible to directly use the wp command to check if the WP-CLI is working properly:

wp --info

A similar message is displayed after execution:

OS: Linux 4.10.0-42-generic #46~16.04.1-Ubuntu SMP Fri Sep 16 14:08:19 EDT 2022 x86_64
Shell: /usr/bin/zsh
PHP binary: /usr/bin/php
PHP version: 7.4.33
php.ini used: /etc/php/7.1/cli/php.ini
WP-CLI root dir: /home/wp-cli/.wp-cli
WP-CLI packages dir: /home/wp-cli/.wp-cli/packages/
WP-CLI global config: /home/wp-cli/.wp-cli/config.yml
WP-CLI project config: /home/wp-cli/.wp-cli/config.yml
WP-CLI version: 1.5.0

2. Reset WordPress password with WP-CLI

It is now possible to use the wp command, the next step is to pass the WP-CLI Steps to reset WordPress password.

First, go to Installation WordPress folder. For example, if WordPress is installed in /var/www/wordpress/ directory, execute the following command to enter the folder:

cd /var/www/wordpress/

Once you are in the WordPress installation directory, use the WP-CLI to list the site's users:

wp user list

After executing this command, you will see a list of all users of the current WordPress site, similar to the following:

Image [2]-Easy Guide to Reset WordPress Password with WP-CLI

If you want to reset the admin The user's password, which can be changed using that user's ID (e.g., ID 1):

wp user update 1 --user_pass=new password

If you want to add a new name for the user3 The user resets the password, using that user's ID (for example, ID 3):

wp user update 3 --user_pass=new password

After executing the above command, the WordPress user's password will be reset successfully. At this point, you can login to WordPress with the new password.

summarize

utilization WP-CLI It is true that resetting passwords is easier than other methods, but this method works for VPSbecause not all hosts support SSH functionality. If the host supports SSHThe WP-CLI is not allowed to upload WP-CLI files and may require the use of the php wp-cli.phar command to operate.

Overall, WP-CLI makes WordPress administration much more efficient and provides a very useful toolset especially when batch operations or frequent system administration is required.


Contact Us
Can't read the tutorial? Contact us for a free answer! Free help for personal, small business sites!
Customer Service
Customer Service
Tel: 020-2206-9892
QQ咨询:1025174874
(iii) E-mail: info@361sale.com
Working hours: Monday to Friday, 9:30-18:30, holidays off
© Reprint statement
This article was written by: thieves will be rats and mice courage
THE END
If you like it, support it.
kudos15 share (joys, benefits, privileges etc) with others
commentaries sofa-buying

Please log in to post a comment

    No comments