Have you ever forgotten your WordPress administrator password and did not have access to your e-mail account or haven’t configured your e-mail account properly in WordPress? Fear not, because in today’s tutorial we are going to learn how to reset the WordPress administrator password through the MySQL command prompt. Resetting WordPress Admin Password via MySQL Command Prompt, its fairly easy task, you will need to have the login credentials of your database and user, or have access to wp-config.php file. Let’s get started!
Resetting the WordPress admin password through MySQL
Let’s begin by looking up the username and password you set for your WordPress database in your wp-config.php file first, do that by navigating to the directory WordPress is installed in and then open wp-config.php with nano:
Find the following lines in your wp-config.php file:
Now that we have all the information we need we are going to open a MySQL command prompt with the following command:
Enter the password when prompted and then enter the following query in the MySQL command prompt:
Look for the users table with the following query:
Use the prefixed users table from the output of the query above in the following query, for an example we’ll use ‘wp_users’. We also use ‘admin’ as the administrator user, your administrator username might be different:
The query above outputs a row containing the current encrypted WordPress password of the administrator user, we are going to change it using this query, be sure to substitute ‘new_password’ for your own password:
Now check if the password has changed:
Then type exit to exit the MySQL command prompt:
Resetting the WordPress admin password through wp-cli
If you do not want to bother going the long route through MySQL you can change your WordPress administrator password with a neat tool called wp-cli which is considered the swiss army knife of WordPress. To download wp-cli execute the following command:
Check if wp-cli is working:
Then make wp-cli executable and move it to ‘/usr/local/bin’:
Now navigate to the root directory of your WordPress installation and then execute the following wp-cli command:
Again, make sure that you replace ‘admin’ with your WordPress administrator username and ‘new_password’ with your desired password.
If you are running wp-cli as root then add the ‘–allow-root’ option at the end of the command like this:
That’s it, now you should have successfully changed the password for your WordPress administrator user.
Of course, you don’t have to reset WordPress admin password via MySQL command prompt yourself, if you use one of our WordPress Hosting services, in which case you can simply ask our expert Linux admins to change your WordPress administrator password for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post on how to reset WordPress admin password via MySQL command prompt, please share it with your friends on the social networks using the buttons on the right or simply leave a reply below. Thanks.