Resetting a WordPress Password

Sometimes you can bite yourself a little when you experiment around with things. I installed a security plug-in and the next thing you know I couldn’t log into my own website. Ouch. Not a huge deal as it actually led to experimentation with the MySQL tables for WordPress, which oddly enough, I’ve typically just left well enough alone. But this I figured was gonna’ need to be updated eventually (although I relished the opportunity to get caught up on some stuff in the meantime). So first up, SSH into your box. Then fire up mysql:

mysql -u root -p

Turns out there’s a wp_users table in there. For my user I was able to do the following (replacing MYUSERNAME with my actual username):

SELECT MYUSERNAME FROM `wp_users`

Then the following (again assuming MYUSERNAME is the user and now substituting MYPASSWORD with the password you want to use – lucky us that md5 is supported from the mysql CLI now, as that’s what WordPress is gonna’ want us to use):

UPDATE wp_users SET user_pass = MD5(‘”(MYPASSWORD)”‘) WHERE ID = MYUSERNAME

And then viola I was back to writing the same old dribble once again. I had been really busy finishing off some chapters and so hadn’t bothered to figure it out. Now I’ll be back to it. Lucky you, right?!?!