Reset WordPress admin password

In case you’ve forgotten WordPress admin password and for some reason can’t recover it using yoursite.com/ wp-login.php?action=lostpassword form, this article will show how to reset password in like 3 minutes.

Using phpMyAdmin

Assuming your hosting have phpMyAdmin (most have) and you remember password, login to phpMyAdmin. Once you’re in, select database from list on the left and them click button SQL (located in top of page) . Blank textarea appears. Paste following code snippet into textarea and change it accordingly to your needs.

update wp_users set user_pass=MD5('newpassword123') where user_login='admin'

Change newpassword123 to actual password and admin to actual admin login .

Click button ‘Go’ below textarea and this message should appear.

That means password is resetted and you can login to WordPress using new password.

Reset password without phpMyAdmin

People often freak out when they haven’t got database manager. Chill. It will take little longer then 3 minutes but isn’t hard. Open text redactor, paste this code:

//connect to mysql
$con=mysql_connect('DB_HOST','DB_USER','DB_PASSWORD');
//select database
mysql_select_db('DB_NAME');
//reset password
 $sql="update wp_users set user_pass=MD5('newpassword123') where user_login='admin'";
//if everything's ok, you password is resetted
if(mysql_query($sql)){
     echo "Your password succesfully resetted!";
}

and save as reset.php

Again, change following values to suit your situation:

First  values are for connecting to database. You must Access to site’s files  – either with ftp client or web interface, then open wp-config.php (in root directory) and search for DB_NAME. It’s expected to look like this:


define('DB_NAME', 'demo');
/** MySQL database username */
define('DB_USER', 'user');
/** MySQL database password */
define('DB_PASSWORD', 'mysqlpass');
/** MySQL hostname */
define('DB_HOST', '127.0.0.1');

As you might suspect, these values should go to reset.php. In my case database’s name is demo, so in reset.php I replace DB_NAME  with demo.
DB_USER to user,  DB_PASSWORD to mysqlpass and DB_HOST to 127.0.0.1. So in the end reset.php looks like this:

//connect to mysql
$con=mysql_connect('127.0.0.1','user','mysqlpass');
//select database
mysql_select_db('<strong>demo</strong>');
//reset password
$sql="update wp_users set user_pass=MD5('newpassword123') where user_login='admin'";
//if everything's ok, you password is resetted
if(mysql_query($sql)){
      echo "Your password succesfully resetted!";
}

newpassword123 will be new password and admin is your login.

If you dont want to copy code,  download reset.php here (.rar file). Upload reset.php to to your site and open yoursite.com/reset.php in browser.

If message ‘Your password succesfully resetted!’ shows, then congratulations – you have successfully resetted WordPress password without phpMyAdmin!

P.S. If your hosting doesn’t have phpMyAdmin, after resetting password you might want to change hosting provider that has it. I’ve been using Hostgator for 3 years and am 100% happy about it.