We all forget our password. That’s why on every web system, there is a forget password link available. WordPress is not an exception. So if we forget our password, and can’t sign in, then we can just use forget password link, and reset our password.
Yes, it will send an email with a password reset link, and we can use that link to reset the password.
But what if your site is not configured to send an email?
In that case, we will need to reset the password manually, directly from the database.
Using MySQL Commands
If you have some development knowledge and comfortable with commands on a black screen, then this will be easiest and super fast way to change the password.
So open terminal/command line, and then ssh to your server.
Inside your server, log in to MySQL using below command:
$ mysql -u root -p
It will ask for the MySQL password. Enter it and then you will be in MySQL command line mode.
In default WordPress installation, the users table name is wp_users. The user password is in encrypted form, that’s why we can’t read it. We can only change it. To reset the password we have to use the MD5 function of WordPress. So, now we will write commands to use our database and then command for changing the password.
Use the following command to use your WordPress database:
mysql> use Yourdatabasename;
Then write this command to get all the users. By this, you can identify the ID of that user for which you want to change the password.
mysql> select * from wp_users;
It will display all users in the database, find the user you want to change password, and note it’s ID. For this example, let’s say the user ID is 5. Now we will write the following command:
mysql> update wp_users set user_pass=MD5('yourpasswordhere') where ID=5;
This will update the password of the user.