How to reset WordPress Password using wpcli
If you lost your WordPress user password, you can use forget password link on the WordPress login screen to reset the password. For any reason, if you were unable to receive the password reset email, you have to reset your password by editing the wp_users table in MySQL Database or by using the WordPress command line tool (wpcli).
If you don’t have wpcli installed, you can install it with
For root users
1 2 3 |
cd && wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar mv wp-cli.phar /usr/local/bin/wp chmod 755 /usr/local/bin/wp |
If you are logged in as a normal user, run the following command
1 2 3 |
mkdir ~/bin wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O ~/bin/wp-cli.phar alias wp="php -d memory_limit=-1 ~/bin/wp-cli.phar" |
To make wp command available when using as normal user, you need to run
1 |
alias wp="php -d memory_limit=-1 ~/bin/wp-cli.phar" |
To make it permanent, you can edit the file ~/.bashrc and add the above line to the end of the file, so it gets executed whenever you log in to the server.
To list all users, you can run
1 |
wp user list |
To list all users with administrator role, run
1 |
wp user list --role=administrator |
To reset the password for a user, run
1 |
wp user update USERNAME --user_pass='NEW_PW_HERE' |
Reset the WordPress user password by editing wp_users table using phpMyAdmin
Back to WordPress