This is something you don’t want to happen, but maybe it will. Maybe not to your main important blog, but to a blog you run. There can be many reasons you lose your password: if you lose your e-mail account associated with the wordpress url, or if some hacker get access trough a badly coded plugin, etc.

You can waste a lot of resources trying to prevent things that are less likely to happen, or you can know what you do to get your account back as soon as possible.

First of all, you have to make sure you use a real e-mail address associated with your account. And make sure that e-mail address don’t have  a password like 123456, 1234, pass and you access that e-mail account at least once a week.

If one day you try to log in into your wordpress account and it says incorrect password many times then you’ve done it, it is lost. If recovery password don’t work then you are in trouble.

If you have cPanel  or hosting account administration account you’re saved. Log-in and look for PhpMyAdmin. Open it, go to your main database, select the table “wp_users” and edit your administrator account. Before you add your new password you should generate one.

Use the md5 online generator and choose a simple password. Now edit the database row with your administrator username and replace the current password with the generated one. Now you should be able to log-in with the password you converted into md5.

If you don’t have cpanel access, you can do it too, but you need at least ftp access. Log in to your ftp account and enter in the directory where wordpress is located. You have to create a php script that will reset your password.

Create a new plain file on your computer and call it change.php . First of all, you need to know the access data to your database: database host ( probably localhost ), database username, database password, database name, and wordpress table prefix if you changed it on installation ( the default is wp_ ). All these info can be found in your wp-config.php file.

Then you need to create a connection to the database, select the desired database and then run a query to update the password. Here is the code, make sure you replace everything you need: database host, user,password,name and wp prefix.

<?php
mysql_connect("database_host","database_username","database_password");
mysql_select_db("database_name");
mysql_query("UPDATE wp_users SET user_pass='". md5('desider_password') ."' WHERE user_login='admin' ");
myslq_error();
?>

Please make sure to replace the bolded code. Now upload the file to your server, and run it on your browser. yourdomain.com/change.php . Check is everything is right.

Make sure to delete the file after you change the password.