How to reset WordPress admin password from database

People who uses lot of login credential may find it difficult to remember all the passwords. In such cases it may be difficult and time consuming to recollect password. There is an option to change the admin password in WordPress via email id. Sometimes it is possible to forget email id as well or that email id doesn’t exist at the moment. In such a case we can reset the WordPress admin password if we have access to database using following method. It is not only possible to reset WordPress admin password but also can be used to reset any WordPress user password.

First you need to login to the database:

[root@web1 ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 650
Server version: 10.2.34-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

To select a database, use the below command:

MariaDB [(none)]> use sf_db
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

WordPress user credentials are stored in the table wp_users, user name is inside user_login column and the password inside the user_pass column.

In this example, we have used the ‘ID’ as a key to change the WordPress admin password. To view the ‘ID’ ,following command can be used:

select id,user_login from wp_users;                           
| id | user_login |
|  2 | admin      |
1 row in set (0.00 sec)

Here we can see that the ‘ID’ for user admin is 2. The WordPress password can be updated using below command:

MariaDB [sf_db]>  update wp_users set user_pass = MD5('Testpass1') where ID = 2;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

Here ‘Testpass1’ is the sample password. We have used MD5 encryption because WordPress accepts MD5 encrypted passwords.

reset WordPress admin password from database

If you like to change the email id of user to use the forget password option, you can use the following article.

Add a Comment

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