How to Reset WordPress Admin Password via MySQL Command Prompt - 21102019

Breaking

Post Top Ad

Responsive Ads Here

Post Top Ad

Responsive Ads Here

Tuesday, July 3, 2018

How to Reset WordPress Admin Password via MySQL Command Prompt

Sometimes, a WordPress user, with one of the following capabilities, such as administrator, editor, author, contributor or subscriber, forgets its login credentials, especially the password.
WordPress password can be easily changed via “Lost password” WordPress login form. However, if the WordPress account has no way of accessing his email address, changing the password using this mechanism can be impossible. In such cases, the job of updating a WordPress account password can only be managed by a system administrator with full privileges to MySQL database daemon. In this guide we will show you how to reset a WordPress account password via MySQL command line in Linux. Before logging in to MySQL/MariaDB database service, first create a MD5 Hash version of the new password that will be assigned to the account, by issuing the below command.
Replace the “newpass” string used in this example with your own strong password. Copy the password MD5 hash to a file in order to later paste the hash to MySQL user password field.
# echo -n "newpass" | md5sum
Create MD5 WordPress Password
Create MD5 WordPress Password
After you’ve generated the new password MD5 hash, log in to MySQL database with root privileges and issue the below command in order to identify and select the WordPress database. In this case the WordPress database is named “wordpress”.
# mysql -u root -p
MariaDB [(none)]> show databases;
MariaDB [(none)]> use wordpress;
Connect and Select WordPress Database
Connect and Select WordPress Database
Next, execute the below command to identify the table responsible for storing WordPress user accounts. Usually the table that stores all user information is wp_users. Query wp_users table to retrieve all users ID, login name and password and identify the username ID field of the account that needs the password changed.
The username ID value will be used to further update the password.
MariaDB [(none)]> show tables;
MariaDB [(none)]> SELECT ID, user_login, user_pass FROM wp_users;
List All WordPress Users in MySQL
List All WordPress Users in MySQL
After you’ve correctly identified the ID of the user that needs the password changed, issue the below command to update his password. Replace the user ID and password MD5 Hash accordingly. In this case the user ID is 1 and the new password hash is: e6053eb8d35e02ae40beeeacef203c1a.
MariaDB [(none)]> UPDATE wp_users SET user_pass= "e6053eb8d35e02ae40beeeacef203c1a" WHERE ID = 1;
Reset WordPress Admin Password in MySQL
Reset WordPress Admin Password in MySQL
In case you don’t have an already MD5 hashed password, you can execute MySQL UPDATE command with the password written in plain text, as shown in the below example. In this case we’ll use MySQL MD5() function to calculate the MD5 hash of the password string.
MariaDB [(none)]> UPDATE wp_users SET user_pass = MD5('the_new_password') WHERE ID=1;
After the password has been updated, query wp_users table with the ID of the user that you’ve changed the password in order to retrieve this user database information.
MariaDB [(none)]> SELECT ID, user_login, user_pass FROM wp_users WHERE ID = 1;
That’s all! Now, inform the user that his password has been updated and it should be able to log in to WordPress with the new password.

No comments:

Post a Comment

Post Top Ad

Responsive Ads Here