WordPress is perhaps the most popular and used CMS (Content Management System) in the world, and grew from a small project open source until today it is found in around 29% of all websites on the web and has more than 45.000 plugins. That is why almost all of us think of him when it comes to start with a blog or even a website, since at this point we can say that the ease it offers for all kinds of projects on the net is well proven.
Of course, beyond its ease of use, it is normal that from time to time we may run into some inconvenience, for example forgetting the access password. And although of course we have methods to reset it (through the 'I forgot my password' link) we may have lost access to the email account with which we registered. So let's show how to reset our WordPress password from the MySQL command line.
The procedure is not complex at all and consists of a few steps, namely:
First we create a version of our password with MD5 hash, which will be assigned to our account through the following command (we replace «new password» with the one we are going to use:
#echo -n "newpassword" | md5sum
We will be given a code of the type e7018eb9d78e02ae40beeeacef203c1a, which we must copy. After this we have to access our MySQL server as root:
#mysql -u root -p
We execute the following command, to select the WordPress database (if we are not using the default name, change it to the appropriate one):
use wordpress;
Now we are going to obtain the ID, login name and password of the account that we need to modify:
SELECT ID, user_login, user_pass FROM wp_users;
Again, wp_users is the generic name with which WordPress creates the tables, but if at the time of installation we have opted for a custom one, we will need to change it to the one we have chosen.
Now let's change Password, and for this we take due note of the user ID that we have obtained in the previous step (for our case, we are going to assume that it is 12) and we enter the password obtained at the beginning of everything, with the MD5 hash:
UPDATE wp_users SET user_pass = «e7018eb9d78e02ae40beeeacef203c1a»WHERE ID = 12;
That's all, if we now run the command again:
SELECT ID, user_login, user_pass FROM wp_users WHERE ID = 12;
We will see that the password is no longer the same as before, and that it has indeed been modified.
Or you can do from mysql:
update wp_users set user_pass = MD5 ('NEW_PASSWORD') where ID = 12;