Password retrieval failed!
August 2nd, 2007
Tonight I forgot my admin password. Thought: no problem! Hit the “Lost Password?” link at the WordPress login screen.
Now, that might happen once in a lifetime: PHP was not able to talk to the local mailserver! Therefore no password was sent!
The first thing to do was a quick ckeck:
function helpme() {
if(mail("please@help.me","test","test")) {
echo "success";
} else {
echo "error";
}
}
helpme();
helpme() returned “success” but nothing happened. No email at my inbox.
After checking DNS-MX records and looking at phpinfo() it was crystal clear that there must be a server misconfiguration. Since I do not have root access to this machine, I wrote a small script, to help me out. It is a simple admin-password resetter containimg a form for setting a new admin password. The POST-value is overwrites the unretrievable on in the WordPress database:
$sql = "UPDATE ".$wpdb->users."
SET user_pass = '".md5($_POST['emergency_pass'])."'
WHERE user_login = 'admin'";
$link = $wpdb->query($sql);
wp_redirect('wp-login.php');
exit();
Download: WordPress Admin Password Resetter
Usage:
- Unzip
- Upload password-resetter.php to your WordPress root (!this is NOT a WordPress Plugin!)
- run http://[your WordPress URI]/password-resetter.php
- set a new password
- Very important: DELETE password-resetter.php
Posted by Roland Rust
File under: Wordpress Plugins
Leave a Reply
See also:
- Find Us in dutch language (January 13th, 2008)
- Plugins in action: Mini-Slides (November 19th, 2007)
- Demo Mode 1.2 released (November 18th, 2007)
- Plugins in action: Mini-Slides on timbuktoons.tv (November 17th, 2007)
- Demo Mode 1.1 released (November 9th, 2007)


August 20th, 2007 at 7:51 pm
Very very cool download! I created a wordpress plugin that you might want to check out…
htaccess password protect wp-admin
February 7th, 2008 at 9:04 am
I’m really rusty with MySQL and PHP, but can’t you just have logged into PHPMyAdmin and look for your username password values??