How to Reset WordPress Password Using MySQL Command Prompt

Post Series: WordPress Password Recovery
  1. 1.How To Reset Your WordPress Password Using phpMyAdmin
  2. 2.How to Reset WordPress Password Using MySQL Command Prompt

Our WordPress Password Recovery series is sorted according to the popularity of the tutorial mentioned. For starters, you have have the most popular recovery option – i.e. using phpMyAdmin.

There are certain web hosting providers who do not provide cPanel and/or phpMyAdmin. What do you do then? Read this article!

WPMYSQL-Cover

Rest assured, since WordPress used one database – (commonly MySQL), every hosting provider must have a Database Management System better known as DBMS. In this tutorial, we’ll be using the MySQL command prompt (abbreviated as CMD) which is a free DBMS as licensed under GNU General Public License v2.

Prerequisites

Recovering your password using the MySQL CMD involves lesser number of steps and can be thought of as an universal password recovery system; in the sense that it can be used in almost any plausible scenario.

However,  you need to have a working understanding of databases and how WordPress interacts with one. Apart from that, you also need to know the following technical aspects:

  • Name of the database being used by the WordPress installation
  • MySQL server address (IP or hostname)
  • MySQL login credentials of the ‘root’ user
  • The user ID of the user whose associated password you want to change. This is typically 1 since, during WordPress installation, we create the admin user. Note that the username of the admin user can be ‘Jack’ or ‘Mike’ or ‘admin’, but the user ID will always be 1, since, this is the first user you’re creating.

Logging in to the MySQL Command Prompt

Windows

If you’re running an offline installation of WordPress in Windows using WAMP or XAMPP, then to launch the MySQL CMD, click on the WAMP icon > MySQL > MySQL console. This directly logs you in. There’s no need to enter any more commands. Head over to the next step.

MySQL Console WAMP

Linux

Most shared hosting providers, VPS, dedicated servers use a variant of Linux which include CentOS, Debian, Fedora or Ubuntu to name a few.

If you are running an offline installation of WordPress in Linux using LAMP, then simply launch terminal emulator and type the command:

mysql -u root -p
If you’re trying to reset the password in a remote server, connect to it via SSH using any SSH client – for example, the world’s favorite client – Putty. Once you have logged in to the remote server, to login to MySQL, use the following command:
mysql -u root -p <password>

Logging into MySQL on a remote server VPS

Resetting the WordPress Password:

Now that you have access to the MySQL CMD indicated by the “mysql >” prompt, its time to work the magic. Well, not magic – just good ol’ MySQL commands. 😀

MySQL Shell

ASSUMPTIONS:

  • WordPress database name: wp_genesis
  • User ID: 1
  • New password: WPEXPLORER

WORKING THE MAGIC:

Enter the following commands ditto:

use wp_genesis;
SELECT ID, user_login, user_pass FROM wp_users;
UPDATE wp_users SET user_pass = MD5(‘WPEXPLORER’) WHERE ID=1 LIMIT 1;

In case the last command does not go according to the screenshot, delete the the single quotes and manually type them in the CMD. That should do the trick.

Reset WP Password from MySQL CMD WAMP

This will reset the password of the admin user to WPEXPLORER. Of course, while setting a new password, you’ll have to use a stronger one. Once done, you can exit the MySQL CMD by using the command:

exit

Video Tutorial

Here’s a video tutorial describing the entire process. I would recommend reading the article first, but if you’re looking for a quick fix, this is your queue:

Conclusion

In conclusion to our WordPress Password Recovery series I’d like to remind you that part (a) is simpler because 90% of the hosting companies come with phpMyAdmin. But if you have some free time, I’d recommend trying out this part (using MySQL) as it’ll give you some experience in handling MySQL commands and databases. And who knows – maybe it’ll be of some use in the future!

Prevention is better than The cure

LastPass

I started this series off by saying how password saving/backup services like LastPass thrive. Don’t get me wrong – it wasn’t my intention to come across as demeaning. I actually love and use LastPass everyday. I have it installed in my phone and in every browser in all my computers. Life (for me) would come to a stand-still without it.  Honestly, I can’t survive without it.

LastPass, as it is one of the most complete and user-friendly password management software out there. I would highly recommend using it. And every time you login to a new website, make sure you actually save the password! 😉

Logos belong to their respective owners. We’re using it for educational purposes only.
Sourav
Post Author: Sourav

Sourav is a WordPress enthusiast, an avid gamer and a sitcom collector. His playlists include heavy metal, electronic, and new-age tracks. When he’s not online, he’s spending quality time with his friends and family. You can follow him on Twitter.

Disclosure: This page contains external affiliate links that may result in us receiving a comission if you choose to purchase said product. The opinions on this page are our own. We do not receive payment for positive reviews.
Got something to say? Join the discussion.
  1. Seth Williams says:
    Hi Sourav. That was very useful. I'll need to bookmark this just in case.
  2. Thank you!!!! WordPress was missing the ; at the end of the commands and was confusing. This was simple and I was able to do the task first try!
  3. Don't blindly follow these instructions. That SQL command will reset all the user passwords. Instead of this: UPDATE wp_users SET user_pass = MD5('WPEXPLORER'); The line should be; UPDATE wp_users SET user_pass = MD5('WPEXPLORER') WHERE ID=1 LIMIT 1;
  4. If you are helping client to recover password, it's better use this rather than phpmyadmin because black windows with white letters always seem more serious and hacker-like ;)
  5. Mufaddal says:
    Worked like a charm. Great work.
  6. Logan Holdaway says:
    I would like some help. I can only get so far. SELECT ID, user_login, user_pass FROM wp_users does not work for me. I'm wondering if it has something to do with my server version. If I type just about anything it doesn't work, even exit. I'm using 5.5.44-0ubuntu0.14.04.1 (Ubuntu). Any ideas?
  7. Thank you it worked !
  8. Thank you sir! I had some hard time remembering the password of an old blog, and I didn't have phpmyadmin installed on my server. Your solution was really helpful and time saving!

Leave a Reply