When installing and running multiple WordPress blogs it is easy to forget the password for one of the accounts used. You are using different login names and passwords for each account now are you? This has happened to me more then once when I’m trying something new and then another project steals my focus or something else comes in between, when I return to the original test I haven’t save the password anywhere or the forget password link isn’t working because I didn’t setup a mailserver or used a disposable email address for that account.
When that happens it’s good to have access to the server because we can always change the password via MySql.
Start by login into your vps and then into mySql.
1 |
mysql -u root -p |
There are a many ways to find and change your password and I’ll show some of them. If you have more ways to update the password, please share with us in the comment section.
All user information is stored in the table wp_users.
First we need to know the ID of the user you are going to change the password for. If you know the username, in this example I will use mikho as username, then we can do this command:
1 |
SELECT ID, user_login FROM wp_users WHERE user_login='mikho'; |
The result would be something like this:
1 2 3 4 5 6 |
+----+------------+ | ID | user_login | +----+------------+ | 5 | mikho| +----+------------+ 1 row in set (0.00 sec) |
But what if you don’t know the username or the above command returns no hits? One option is to look for all users that has mikho somewhere inside the username, for this we will need to change the SQL query a little bit and use LIKE in the where clause:
1 |
SELECT ID, user_login FROM wp_users WHERE user_login LIKE '%mikho%'; |
This will return all rows with the word mikho in it.
Or you can list all users then by excluding the WHERE clause:
1 |
SELECT ID, user_login FROM wp_users; |
Now we are ready to set the new password. If we look back at the information provided above the ID for the user mikho is 5.
That gives us the following query to run, notice the 5 at the end of the query that defines what user to update and the password will be set to topsecretpassword. Change both ID and topsecretpassword to match your settings.
1 |
UPDATE wp_users SET user_pass=md5('topsecretpassword') WHERE ID=5; |
All done! You should now be able to log on to your WordPress blog with your new password.
1 comment for “WordPress: Reset forgotten password”