WordPress / 3 MIN READ
WP Database User Passwords
How to reset user passwords in WordPress
From the original Fervor library. Examples may use older package versions.
Tutorial: Accessing the WordPress Database and Changing User Passwords
Sometimes, you may need to change a WordPress user password directly from the database—such as if you lose admin access or cannot reset the password through email. This guide will show you how to securely access your database and change a WordPress user password.
Step-by-Step Instructions
1. Access Your Database via phpMyAdmin
-
Log In to phpMyAdmin:
- Most hosting providers offer phpMyAdmin for database management.
- Access phpMyAdmin via your hosting control panel. For local environments (e.g., MAMP), navigate to
http://localhost:8888/phpMyAdmin/.
-
Locate Your WordPress Database:
- In phpMyAdmin, you’ll see a list of databases on the left sidebar.
- Identify the database associated with your WordPress site. If unsure, check the
wp-config.phpfile in your WordPress root directory. Look for this line:define('DB_NAME', 'your_database_name');
-
Select the Database:
- Click on the database name to view its tables.
2. Find the User Table
-
Open the
wp_usersTable:- In the database, locate the
wp_userstable. (The table prefix may vary, such aswp_orcustomprefix_, depending on your setup.)
- In the database, locate the
-
View Users:
- Click on the
wp_userstable to display the list of registered users.
- Click on the
3. Edit the User Password
-
Locate the User:
- Find the user whose password you want to change. Look for their username in the
user_logincolumn.
- Find the user whose password you want to change. Look for their username in the
-
Edit the User Row:
- Click the Edit button (pencil icon) next to the user’s row.
-
Change the Password:
-
In the
user_passfield:- Replace the existing password hash with a new hashed password.
- Use the MD5 hashing function to encrypt the password.
Example:
- To set the password to
newpassword123, enter the MD5 hash ofnewpassword123:482c811da5d5b4bc6d497ffa98491e38
-
-
Save Changes:
- Scroll down and click Go to save the updated password.
4. Generate an MD5 Password
If you don’t have an MD5 hash generator handy, use an online tool or PHP code to generate the hash:
-
Online MD5 Generator:
- Search for “MD5 hash generator” online and input your new password to get the hashed value.
-
PHP Code (Optional):
- Run this PHP code snippet locally or on a server:
<?php echo md5('newpassword123'); ?>
- Run this PHP code snippet locally or on a server:
5. Test the New Password
-
Log In to WordPress:
- Visit your WordPress login page (
http://yourdomain.com/wp-admin). - Use the updated username and password to log in.
- Visit your WordPress login page (
-
Verify Access:
- Ensure you can access the dashboard and perform actions as expected.
Important Notes
-
Use Secure Hashing:
- WordPress uses more secure hashing methods (like bcrypt) by default. If you log in using the MD5-hashed password, WordPress will automatically update the hash to a more secure version.
-
Backup Before Making Changes:
- Always create a backup of your database before making manual edits.
-
Avoid MD5 for Permanent Solutions:
- While MD5 is quick for temporary fixes, rely on WordPress’s default hashing for long-term security.
Conclusion
Editing the WordPress database via phpMyAdmin is a reliable way to reset user passwords when other methods fail. By carefully following these steps, you can regain access to your WordPress admin area while ensuring the integrity of your site’s database.