How to change your WordPress login password Print

  • 8

Changing a WordPress password from the database can be a useful option if you’ve forgotten your admin password or if you’re locked out of your WordPress site. This process involves accessing your site’s database through a tool like phpMyAdmin, which is commonly provided by web hosting providers. Here is a detailed step-by-step guide on how to change the WordPress password directly from the database:

1. Accessing the Database via phpMyAdmin

Before we begin the process of changing your password, you need to log into the database management tool provided by your web host. This is usually done via phpMyAdmin.

Steps to Access phpMyAdmin:

  • Log in to your hosting account: Most web hosting services (like Bluehost, SiteGround, or HostGator) provide a control panel like cPanel or Plesk.
  • Locate the phpMyAdmin tool: In your control panel, search for or find the phpMyAdmin option. It’s usually under the Databases section.
  • Log in to phpMyAdmin: Once you’re in phpMyAdmin, you’ll be asked to select a database. If you don’t know which database is associated with your WordPress site, you can find it in the wp-config.php file, which is located in the root directory of your WordPress installation.

2. Finding Your WordPress Database

If you have multiple databases, you need to know which one WordPress is using. Here’s how to find that out:

  • Open wp-config.php: This file is located in your website’s root directory (where WordPress is installed). You can access it via an FTP client (like FileZilla) or through your hosting control panel’s File Manager.
  • Look for the database name: Open the wp-config.php file and search for the line that says:phpCopy codedefine('DB_NAME', 'your_database_name'); The value 'your_database_name' is the name of the database associated with your WordPress site.

3. Selecting the WordPress Database in phpMyAdmin

Now that you know the database name, go back to phpMyAdmin and select the correct database from the left-hand sidebar. Once selected, phpMyAdmin will display a list of tables in that database.

4. Locating the Users Table

Once you’re inside your WordPress database, you’ll see a list of tables. Look for the table named something like wp_users (the “wp_” prefix might be different if you used a custom prefix when installing WordPress).

  • Click on the wp_users table: This table contains the user data for your WordPress site, including usernames, passwords, and user roles.
  • Find the User Record: Inside the wp_users table, you’ll see a list of rows. Each row represents a different user account. Find the user account for which you want to change the password.

5. Editing the User’s Password

  • Click on Edit: Once you’ve located the correct user account (likely the one with the admin role), click the Edit link next to that user.
  • Find the user_pass field: This is where the password for the user is stored. You’ll see a long string of characters here. This is not the password itself but a hashed (encrypted) version of the password.
Changing the Password:

To change the password, you need to:

  • Enter a new password: In the user_pass field, delete the existing string.
  • Choose the MD5 option: From the dropdown menu under the Function column next to the user_pass field, select MD5. WordPress uses MD5 to hash the password before storing it in the database. This is important because if you don’t select MD5, WordPress will not recognize the password correctly.
  • Enter the new password: In the Value field, type the new password that you want to set for the user. Remember, WordPress will store the password as an MD5 hash, so you don’t need to manually hash the password—phpMyAdmin will do this for you once you select MD5.

6. Saving Changes

Once you’ve entered the new password and selected MD5 as the hash function, scroll down and click the Go button at the bottom to save your changes. This will update the password in the database.

7. Logging into WordPress with the New Password

After saving the new password in phpMyAdmin, you can now go back to your WordPress login page (usually http://yourdomain.com/wp-login.php) and log in with the username and the new password you just set. The system will recognize the MD5 hash and authenticate you successfully.

8. Why Use MD5?

WordPress uses MD5 (Message Digest Algorithm) for password hashing. MD5 is a cryptographic hash function that turns the original password into a fixed-length string of characters, which is very difficult to reverse. However, it’s not the most secure hashing method by today’s standards, and WordPress has since moved to more secure hashing methods like bcrypt. But since WordPress still uses MD5 for compatibility with older versions and user convenience, you must use this method when changing the password manually through the database.

9. Additional Security Measures

Once you’ve successfully changed the password, it’s a good idea to take additional steps to ensure the security of your WordPress site:

  • Enable Two-Factor Authentication (2FA): For better security, consider installing a WordPress plugin like Google Authenticator or Wordfence to enable 2FA for logging in.
  • Change Your Password Regularly: Regularly update your WordPress admin password to keep your site secure.
  • Use a Strong Password: Ensure that your new password is strong, meaning it should include a mix of upper and lower case letters, numbers, and special characters.
  • Check for Malware or Vulnerabilities: If you suspect that your site has been compromised, consider running a security scan to look for malware or vulnerabilities.

10. Troubleshooting Tips

 
  • If you can’t find the wp_users table: It’s possible your WordPress installation has a custom table prefix. Open the wp-config.php file again and look for the line that starts with:phpCopy code$table_prefix = 'wp_'; This will show you the prefix used by your installation, and you should look for a table with that prefix (e.g., mycustomprefix_users).
  • If you still can’t log in: If after changing the password you can’t log in, make sure you’re using the correct username and that there are no typos. Sometimes clearing your browser cache or using incognito mode can help resolve login issues.

Was this answer helpful?

« Back