rest wordpress admin password

How to Reset WordPress Admin Password Via MySQL

WordPress is a popular blogging and content management system used by millions of websites and organizations. It allows you to manage multiple users and editors from a single dashboard. It also provides secure admin management with encrypted credentials. However, often administrators may need to reset WordPress admin password in case they have forgotten/misplaced it, or for general security purposes. WordPress allows you to do it via its Login interface. It allows you to send password reset email to yourself. But if you are unable to access your email address then you may need to do this via the back end MySQL database. In this article, we will learn how to reset WordPress admin password via MySQL.


How to Reset WordPress Admin Password Via MySQL

By default, WordPress encrypts user passwords as MD5 hash. So you need to first get the MD5 has version of your password.

1. Get MD5 hash of password

Open terminal and run the following command to get MD5 version of your password. Replace mypassword with your password. Please use a strong password consisting of Uppercase & Lowercase letters, numbers and symbols.

# echo -n "mypassword" | md5sum

The above command will output the MD5 version of your password. Please note it since you will need it later.

2. Log into MySQL database

Log into MySQL database with the following command. Enter MySQL password when prompted.

# mysql -u root -p

Switch to wordpress database with the following command.

> use wordpress;

3. Update Administrator password

In WordPress database, wp_users is the table that stores username password of all users including administrators. You can view its contents with the following SQL query.

> SELECT ID, user_login, user_pass FROM wp_users;

Please note, when you setup WordPress, the first user is generally the administrator so it has the ID=1 in most cases. If not, you can always get the ID of your administrator user from the output of above command.

You can view the credentials of WordPress administator with the following command.

> SELECT ID, user_login, user_pass FROM wp_users WHERE ID = 1;

Please note, the user_pass column will contain the MD5 encrypted version of your password, not the actual password. WordPress encrypts your password before storing it.

You can update the administrator password with the following command. Replace <encrypted_password> with the MD5 hash we obtained in step 1 above.

> UPDATE wp_users SET user_pass= "<encrypted_password>" WHERE ID = 1;

Alternatively, you can also use MD5 function to encrypt and then store the encrypted password in MySQL table, using MD5 function, as shown below. In this case, replace mypassword with your new password.

> UPDATE wp_users SET user_pass = MD5('mypassword') WHERE ID=1;

Once you have updated the WordPress administrator password, you can verify it with the following query.

> SELECT ID, user_login, user_pass FROM wp_users WHERE ID = 1;

In this article, we have learnt how to reset WordPress admin password.

Also read:

How to Stop SetInterval Call in JavaScript
How to Store File Content in Shell Variable
How to Sort Array Objects By Multiple Properties
How to Get Position of Element in HTML
How to Get Duplicate Values in JS Array

Leave a Reply

Your email address will not be published. Required fields are marked *