fervor [>]CODING & CURIOSITY
FERVOR LEARNING SYSTEMTUTORIALS
← WordPress

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

  1. 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/.
  2. 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.php file in your WordPress root directory. Look for this line:
      define('DB_NAME', 'your_database_name');
      
  3. Select the Database:

    • Click on the database name to view its tables.

2. Find the User Table

  1. Open the wp_users Table:

    • In the database, locate the wp_users table. (The table prefix may vary, such as wp_ or customprefix_, depending on your setup.)
  2. View Users:

    • Click on the wp_users table to display the list of registered users.

3. Edit the User Password

  1. Locate the User:

    • Find the user whose password you want to change. Look for their username in the user_login column.
  2. Edit the User Row:

    • Click the Edit button (pencil icon) next to the user’s row.
  3. Change the Password:

    • In the user_pass field:

      • 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 of newpassword123:
        482c811da5d5b4bc6d497ffa98491e38
        
  4. 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');
      ?>
      

5. Test the New Password

  1. Log In to WordPress:

    • Visit your WordPress login page (http://yourdomain.com/wp-admin).
    • Use the updated username and password to log in.
  2. Verify Access:

    • Ensure you can access the dashboard and perform actions as expected.

Important Notes

  1. 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.
  2. Backup Before Making Changes:

    • Always create a backup of your database before making manual edits.
  3. 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.

Keep your curiosity going.Explore more WordPress →
287 TUTORIALS · 22 TOPICSREADY