Loading...

WordPress

Reset WordPress Password Directly in Database

My current job has found me in a sea of WordPress sites. Since we don’t allow (or want, at this time) users to register, the PHP mail() function is not enabled along with the security risks that PHP mail(); brings along with it. So what happens when a user needs their password reset? Currently, an admin has to manually set a new password. That’s fine and dandy but what happens if you only have one admin account and you’re locked out?

The answer to that question is simple – reset the password directly in the database. Before you do that however, the new password needs hashed using MD5. This tool is simple and straight forward for hashing a string.

Once you’ve got your hash, go into your WordPress database, and then find the ‘wp_users’ table. Inside of that table is a column called ‘user_pass’ – this is the field to enter your hash into.

Execute the following SQL command (adjusted for your specific parameters):

UPDATE wordpress.wp_users t SET t.user_pass = 'your-generated-md5-hash' WHERE t.ID = 1;

Replace “wordpress” with your database name and make sure you have the correct ID if you have multiple users otherwise, someone else is getting a new password.

“This can also be handy when installing WordPress within MAMP or MAMP Pro. I’ve found that in verisons 5 and 6 of MAMP Pro, when adding WordPress as an extra, the password you enter before MAMP installs WordPress never works. So, I’ve used this method to fix several WordPress installs when done through MAMP.

Leave a Comment

Your email address will not be published. Required fields are marked *

To top