Changing WordPress User Password Using MySQL
Managing user accounts is an essential part of maintaining a WordPress site, and there may be instances where you need to reset a user’s password directly through the database. This guide will walk you through the steps to change a WordPress user password using MySQL.
Why Change the Password via MySQL?
There are several reasons you might want to change a WordPress user password through MySQL:
- You have lost access to the WordPress dashboard.
- You need to quickly reset a password for a user who can’t access their account.
- You’re migrating or restoring a site and need to ensure user access.
Prerequisites
Before you begin, ensure you have:
- Access to your server via SSH or a terminal.
- MySQL installed and running on your server.
- Administrative access to the MySQL database containing your WordPress installation.
Step-by-Step Instructions
Step 1: Access MySQL
- Open your terminal (Linux/Mac) or Command Prompt (Windows).
- Log into MySQL as a user with administrative privileges (usually
root):
mysql -u root -p
Enter your MySQL root password when prompted.
Step 2: Select the WordPress Database
- Select your WordPress database. You can list all databases using:
SHOW DATABASES;
Once you identify your WordPress database, switch to it:
USE your_wordpress_database_name;
Step 3: Change the Password
- Update the password for the user. WordPress stores passwords in the
wp_userstable, and passwords are hashed. You can use theMD5function to hash the new password. Here’s the command:
UPDATE wp_users SET user_pass = MD5('new_password') WHERE user_login = 'username';
Replace new_password with the desired password and username with the actual username of the WordPress account.
Example
For instance, to change the password for a user named admin to MyNewPass123, you would run:
UPDATE wp_users SET user_pass = MD5('MyNewPass123') WHERE user_login = 'admin';
Step 4: Confirm the Changes
- Check if the update was successful:
SELECT user_login, user_pass FROM wp_users WHERE user_login = 'admin';
You should see the hashed version of your new password.
Step 5: Exit MySQL
- Exit the MySQL shell:
EXIT;
Step 6: Test the New Password
- Log in to your WordPress admin panel using the new password.
Important Considerations
While using MD5 for password hashing is a quick solution, it is not the most secure method. Modern WordPress installations use stronger hashing algorithms. After logging in with the new password, consider resetting it through the WordPress dashboard to ensure it’s stored securely.
Summary
Changing a WordPress user password using MySQL involves the following steps:
- Log into MySQL.
- Select your WordPress database.
- Update the user password using:
UPDATE wp_users SET user_pass = MD5('new_password') WHERE user_login = 'username';
- Confirm the change and exit.
By following these instructions, you can quickly regain access to your WordPress site and manage user accounts effectively.

Leave a comment