How to Change WordPress Admin Password From Database

Changing the wordpress admin password can be challenging. If you don’t have any options. WordPress allows us to change password using email. But Sometimes we don’t have access to that email. Also, If you have access to cpanel you can directly access the admin Dashboard.

Change WordPress Admin Password From Database

Sometimes, you don’t have access to cpanel but anyhow you can access the database. I’ve been working as a web developer and I faced this situation many times. Most of the time when I transfer backup of a site from one server to another server using the famous migration plugin All in one wp Migration” It requires password of old site to login. So this is the trick that I mostly use.



I just want to mention that this trick only works if you have access to database. I am going to create this tutorial for you in localhost. I’ll be using phpmyadmin to view my database and there will do the trick.

Steps to Change wordpress admin Password from Database:

Let’s suppose This is the site That you want to login. And I am unable to access the admin.

Wordpress Login Screen


And Let’s suppose I’ve access to database of site. For Example in my case Here is list of all my databases in phpmyadmin page:

Database List in phpmyadmin

There could be a lot of databases in your case. There are 7 Databases in my case.

  • Information_schema (Default)
  • menu (Custom Database)
  • mysql (Default)
  • performance_schema (Default)
  • phpmyadmin (Default)
  • site (Custom Database)
  • test (Default But Can be deleted)

Kindly Focus only on Custom Databases. Because We have nothing to do with Default ones.
Now, If you are unsure about which database belongs to target site. You will have to explore file manager of your current site.
From your file manager go to Public html > yousite’s main directory . You should be able to find wp-config.php file there. Open that file. In that file you need find following line of code:

/** The name of the database for WordPress */
define( 'DB_NAME', 'menu' );

Now, Where in my code it says “menu“. It should be name of your site’s database. And you can find the same database name. In my case databse name is “menu“. You should be able find exactly the same name in the list of databases in phpmyadmin (Or in your databases).

Now open The target Database. I am opening the database menu. A complete list of all the database tables will be in front of you. Now you should be able to find the table “wp_users” in that list.

Tables in database

Open that table. And you will see a list of all the users there. This is list of all the registered users on your wordpress website. In my case there is only one user( user_login = admin ). But in your case the list can contain hundreds of users. Now You will have to guess here. Which Users could be an admin of site. One thing that I can tell you is The user with smallest ID number is always an admin. Checkout the screenshot at my end.

Users list

Once you are clear about the admin user. You can edit that user. By clicking on the “Edit option” before the user row. You will see similar options as shown in my screenshot.

Editing Single User

Find the Option “user_pass” in the list. In the value column you will see a random string. This is actually Users’s password. Password are stored in like this in database to avoid leakage of actual passwords. The Strings are generated Using md5 Algorithms (You can google this term if you want to learn more. I’ll soon write about this function in detail).
Now. Let’s come back to the point. What you need to do now?

You can simply remove that random string and you can replace that string with any password that you want to set and from the dropdown to the left select MD5 function. Checkout the screenshot below.

Change Password

Now once you are done Scroll down a bit and hit go button.

Run Database Query

Once all this is done. You can now simply login to the site using the new password. I know this could be challenging for the users using linux servers. The procedure could be a bit different but if you have good knowledge of using database on linux then it is easier for you follow the same steps for linux server. But Don’t worry, I’ll soon write a blog on how to change wordpress password when the server is on linux.

If you like this blog please do me a favour and share it with other wordpress newbies so they can also learn. I’ve been working on wordpress for years and I like to share all my experiences with you through my blogs.
Have a nice day! 🙂

Leave a Comment