How to Change a WordPress Admin Password in the Database

Introduction

Forgetting your WordPress admin password and being locked out of your website can be frustrating. If you cannot reset your password via the login page, you can change it directly in the database using phpMyAdmin or another database management tool. This guide will walk you through the process step-by-step.

Why Change the WordPress Admin Password via the Database?

There are several scenarios where resetting the WordPress admin password through the database is necessary:

  • You’ve lost access to your WordPress admin dashboard.
  • The password reset email is not working.
  • You need to reset the password for another admin user.
  • Your website has been hacked, and you need to regain access.

Step-by-Step Guide to Changing the WordPress Admin Password in phpMyAdmin

Step 1: Access Your Database via phpMyAdmin

  1. Log into your web hosting control panel (e.g., cPanel, Plesk, or another hosting dashboard).
  2. Locate and open phpMyAdmin under the database section.
  3. Find your WordPress database from the list of available databases.

Step 2: Locate the Users Table

  1. In phpMyAdmin, click on the wp_users table (the table prefix may be different, such as wp6_users if you have a custom prefix).
  2. Browse the list of users and find the row with your admin username.
  3. Click on Edit (or the pencil icon) next to the admin user entry.

Step 3: Update the Password Field

  1. Locate the user_pass field in the user data.
  2. Change the function dropdown next to the field to MD5 (this encrypts the password).
  3. Enter your new password in the Value field.
  4. Click Go or Save Changes to update the database.

Step 4: Log in to WordPress

  1. Return to your WordPress login page (yoursite.com/wp-admin).
  2. Enter the admin username and the new password you set.
  3. Click Log In to access your dashboard.

Step 5: Reset the Password Again in WordPress (Recommended)

Since MD5 encryption is outdated, WordPress will automatically update the password to a more secure hashing method upon login. However, it’s a good practice to reset the password again from Users > Your Profile inside the WordPress dashboard.

Alternative Methods to Reset the WordPress Password

If phpMyAdmin is not accessible, you can try the following alternatives:

  • Use WP-CLI: If you have SSH access, run:wp user update admin --user_pass="NewSecurePassword"
  • Edit the Functions.php File: Temporarily add the following code to your theme’s functions.php file:wp_set_password('NewSecurePassword', 1);Reload your website, then remove the code immediately after logging in.

Final Thoughts

Resetting the WordPress admin password via the database is a quick way to regain access to your website when traditional methods fail. Always ensure you use a strong password and keep your database secure. If you frequently experience login issues, consider enabling two-factor authentication (2FA) or using a password manager to keep track of your credentials.

By following these steps, you can efficiently reset your WordPress admin password and regain control of your website without hassle.

Picture from: Engineering Vetores por Vecteezy