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 wp-cli installed, you can install it with
For root users
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
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
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
wp user list
To list all users with administrator role, run
wp user list --role=administrator
To reset the password for a user, run
wp user update USERNAME --user_pass='NEW_PW_HERE'
Reset the WordPress user password by editing the wp_users table using phpMyAdmin
Back to WordPress
Leave a Reply