2008/01/27

Lost password recovery

Do you have weak and often failing memory as I do? And what worse, have you forgotten password you are accessing your beloved Moodle with? It is catastrophe! Really?

I assume you know, that Moodle can send you new password in case you have forgotten the old one when you provide username or email you registrated.


But what to do, if you have forgotten absolute everything or your Moodle is not sending emails? (Maybe you are trying Moodle on your localhost without smtp settings etc.)

If you have access to database (phpmyadmin is most used) you are saved.

You need to run this query:

UPDATE `mdl_user` SET password = md5('newpassword') WHERE username = 'admin';

where newpassword is you new password and admin is a username of account you want to set that new password.

Or you can use this script from Shane Elliot:

  • download it
  • modify lines

$username = 'username';
$newpassword = 'newpassword';

  • copy this file to your root moodle installation directory, same location as config.php and access this script with your browser (eg. "http://yourmoodleurl/passchange.php" )
Don't forget to delete this script after usage, it can create security issue!

I hope you regained your password and you are good to go with using Moodle once again ;).

7 comments:

Anonymous said...

Thanks for your shared information.
It helped me a lot.
Thanks again.

admin said...

Thanks for your shared information.
It helped me a lot.
Thanks again.

Anonymous said...

i have the same problem can i have the script?
thanks

Gwandalan PS Blog said...

Thanks!!! query worked fine.

octern said...

This method no longer works with many moodle installations, because they use a "salt." This means that the hashed version of your password won't just be md5('newpassword'); it will be different on every system.

To get around this in just a few (additional) steps, see this post on moodle.org:
http://moodle.org/mod/forum/discuss.php?d=18103#p765509

Abhishek Kumar said...

i was thinking of reinstalling moodle
but it saved me lot of time

thanks ... it worked

Anonymous said...

Wow, thank you so much! I can now finish my homework.