Installation help

 
 
Picture of Alex Saevich
change admin's password
 
Hi, everybody.
I've forgotten admin's password in my moodle instance. I have some experience in database adminestration, so i've found method to change admin's password rihgt in my MySql database (called moodle).
And when I connect to this db...like this,

admin -

I use new password and connection is successfull

but moodle doesn't see new password

what's wrong?

Sorry for my English.
 
Average of ratings: -
Picture of Shane Elliott
Re: change admin's password
Group Developers
You have changed the password to access the database. Moodle user's (including the moodle admin) details are stored within the database.

If you need to reset your password, just click on the 'Send my details via email' button on the login page. Then enter your email address and an email will be sent to you with instructions for resetting the password.
 
Average of ratings:Useful (1)
Picture of Alex Saevich
Re: change admin's password
 
Thaks for feedback.

Some details. My moodle is newbie and all are in localhost.
I haven't any valid smtp parameters in my moodle. So, I cannot send any mail from moodle.

What can I do in this situation?
 
Average of ratings: -
Picture of Shane Elliott
Re: change admin's password
Group Developers
Two options for which you will need to access the database directly. (phpMyAdmin is great for doing all this rather than using command line mysql)

1. In the user table set the email field of the admin account to a localhost address eg root@localhost and then request a password reset for that address
Moodle will only use the SMTP settings if you have already set them. Otherwise it will use the internal PHP mail function. This should work fine for a local address.

2. Can you log in or set up a general user account? If so then have a look here:
http://moodle.org/mod/forum/discuss.php?d=18034

And if the above fail, try the attached script. Put it in the root moodle folder (the same location as config.php) Edit the username and password to suit. Then call it directly from your browser eg http://localhost/moodle/passchange.php
You may want to delete it afterwards as it is a security risk.
 
Average of ratings:Useful (10)
Picture of Alex Saevich
Re: change admin's password
 
You are the great! cool
Thanx for the very useful answer.

I've used your script. I think it's the shortest way to solve same problem.

And the last question (I hope it will be last smile )
However, where moodle does keep the admin's password?




 
Average of ratings: -
Picture of Shane Elliott
Re: change admin's password
Group Developers
Passwords for all users (including admin) are stored (encrypted) in the 'user' table.
Admins are just normal users with an additional entry in the 'user_admin' table.
 
Average of ratings:Useful (1)
Picture of Ahmed Metwally
Re: change admin's password
 

Elliott, you really are a great guy. Such a scribt was very useful for me. It helped me a lot. I guess all moodle admins shoud visit this topic.

Thanks a lot,

 
Average of ratings: -
In Seattle
Re: change admin's password
 

I am trying to get into 1.7 to move the info to our new moodle. 1.9.2 .... but don't have my passcode as admin.

my moodle is on the server within a website

slipcovernetwork.com/sse-classes so when I go into config php I don't find my admin password, I find the site password.

Suggestions anyone.

Karen

slipcovernetwork@gmail.com

 
Average of ratings: -
Picture of Dennis Flynn
Re: change admin's password
 
Shane Elliot's response about the password being stored encrypted is the key. If you change the password, you have to use an md5 hash. I'm sure it's easy enough at the command line, but in phpMyAdmin you just open the record for the user, type in the new password in the password field, and choose the md5 option in the drop-down box.
 
Average of ratings:Useful (2)
Picture of Seiti Yamashiro
Re: change admin's password
 
Or just insert

d41d8cd98f00b204e9800998ecf8427e


as a password. Because
MD5("") = d41d8cd98f00b204e9800998ecf8427e, so now your passoword is a empty string.
 
Average of ratings:Useful (6)
Picture of luiz rosalba
Re: change admin's password
 
so moodle uses md5 ... thats an important thing to know...
 
Average of ratings: -
Wild and Free!
Re: change admin's password
 

Worked well! Thank you!

 
Average of ratings: -
CJ con sombrero australiano
Re: change admin's password
 

That empty string is very useful, Seiti Yamashiro, thanks!

 
Average of ratings: -
Pablo Espanola
Re: change admin's password
 
Thank you, Seiti Yamashiro! Your idea works very well! I was able to access my site after I lost access as a result of an upgrade. Great idea! Pablo
 
Average of ratings: -
Picture of J Guzman
Re: change admin's password
 

Thanks Seiti, this solution worked great.

 
Average of ratings: -
Picture of Chris Baldwin
Re: change admin's password
 

This one worked for me - 7 years after the original post - using M2.6 - on localhost after an upgrade:

"Shane Elliot's response about the password being stored encrypted is the key. If you change the password, you have to use an md5 hash. I'm sure it's easy enough at the command line, but in phpMyAdmin you just open the record for the user, type in the new password in the password field, and choose the md5 option in the drop-down box."

Dennis Flynn - 2007.

 
Average of ratings: -
Sketch...
Re: change admin's password
Group Particularly helpful Moodlers

An easier way is to use phpMyAdmin to copy the password hash from a profile that you do know the password for and update the profile whose password you need to change with that known password hash. e.g.:

SELECT password FROM mdl_user WHERE id = <the id of a moodle profile that you DO know the password for>;

UPDATE mdl_user SET password = <the password from above> WHERE id = <the id of the profile whose password you have forgotten>;

Then login to the profile with that password and change the password to something you won't forget...

I might be wrong, but I I don't think the password algorithm is a straight MD5 hash. I think it's a bit more complicated than that.

 
Average of ratings: -
Gmads
Re: change admin's password
Group Particularly helpful MoodlersGroup Testers

Hi Luis,

It's MD5 in older versions, since 2.5 it's a stronger algorithm.

 
Average of ratings: -
Picture of Michael J. Ryan
Re: change admin's password
 

Hi Shane,

I have no 'User_Admin' table.  When installing Moodle during the database creation process I received no error messages.  So, why is this table missing and what can be done about it?

Also, maybe you can answer this for me.  I've seen references to 'Admin -->Configuration.  I assume that 'Configuration' is an option on the Administration menu.  But when I login (I'm the administrator), the Administration menu has no such option either at the top level or within any of the other options.  Am I looking in the wrong place or is it missing?  What do I do in either case?  (I'm using Moodle 1.8)  Thanks.

Mike Ryan

 
Average of ratings: -
Picture of Radik Kalakay
Re: change admin's password
 
The table called mdl_role_assignments.
 
Average of ratings: -
Picture of harvey hall
Re: change admin's password
 

For some reason when I look into the table with all the users, there is no admin no matter which way I sort them. Any suggestions?

Thanks

Harvey

 
Average of ratings: -
Picture of John Spradlin
Re: change admin's password
 

Once I got into the database, i just changed the email associated with the admin account and then used the forgot password option.

 
Average of ratings: -
Picture of Gorka Solana
Re: change admin's password
 
Elliot:
Thanks a lot, for the script.

 
Average of ratings: -
Picture of Tom Ceresini
Re: change admin's password
 
Thanks, Shane. Your script was a big help.
 
Average of ratings: -
Picture of Lin Reigu
Re: change admin's password
 
Hi Shane,

You are an awesome guy. People like you restore my faith in humanity. You've just saved me from a major headache.

yours,

Lin
 
Average of ratings:Useful (1)
Picture of Elya Nilas
I need step by step on chaning admin pswd in MySql
 
Please help as I have tried sending a reminder of pswd e-mail, but the login will just NOT accept it for some reason. Seems like i have to go the MySQL side an dchange it there. Can somebody tell me step by step on where in MySQL I have to go and specifically in the table of MDL_USER? If yes, then what do I do and which filed I go to and what do I look for in there and what do I chagne. Please advise. I do apologize but with today's world of 25,000 pswds I just..lapsed out.
 
Average of ratings: -
Capt. Moodle
Re: I need step by step on chaning admin pswd in MySql
 
Average of ratings: -
Picture of Elya Nilas
Re: I need step by step on chaning admin pswd in MySql
 
No. I have tried to change the pswd via MySql by going to mdl_user table and browsing for the field Password. I have then changed it to "whatever I typed" and selected MD5 from drop down list. I have since tried to log on to the course but it WON'T allow me in. Period. Any suggestions?
 
Average of ratings: -
Capt. Moodle
Re: I need step by step on chaning admin pswd in MySql
Group DevelopersGroup Moodle HQGroup Particularly helpful MoodlersGroup Testers
I am glad that we were able to get you working again by using phpMyAdmin to change the record in mdl_config where name=dbsesssions from 0 to 1. This allows for the sessions to be handled by the database rather than stored on the filesystem. I suspect that your problem is a permissions issue which I hope you will be able to resolve with your host. If not, at least you can have your site up and running even if it costs you a few more queries and database activity. Happy Moodling.
 
Average of ratings: -
Picture of Jeff Hague
Re: change admin's password
 
Very, very helpful - thanks!
 
Average of ratings: -
Picture of William Oakes
Re: change admin's password
 
Thank you, Shane! It is now 2008 and your script still works wonders!

However, I had to run "localhost/passchange.php" and not "localhost/moodle/passchange.php" in order for the browser to find the file. Probably just my setup but I thought I would post a word about it for posterity.

Again, THANKS!

Bill
 
Average of ratings:Useful (1)
Picture of Richard Enison
Re: change admin's password
 
WO,

That's exactly what it is. Some Moodle sites are set up so that the main Moodle directory (where index.php, install.php, config.php, config-dist.php, etc. are), usually called moodle, is the web document root (aka home directory), so that Moodle is accessed as localhost or yourmoodledomain.com, etc. Others have moodle as a subdirectory of the root, so they have to use localhost/moodle or yourmoodledomain.com/moodle. It's a matter of how the webserver s/w (Apache, IIS, etc.) is configured, although I think it is also possible to change it by messing with the DNS records.

RLE
 
Average of ratings: -
Scott van Niekerk
Re: change admin's password
 

Any suggestions for if I can no longer login to my moodle on my server?

Is there a standard admin username and xxx password? Or which of my files would I look in to detect that info?

Thanks

 
Average of ratings: -
Picture of Richard Enison
Re: change admin's password
 
SvN,

Read the rest of this thread. That's what it's all about! I can tell you where it's stored (it's in the database, unless you're using a non-standard authentication method), but it's encrypted, so you can't "detect" it. But you can change it to whatever you want it to be. You have your choice of methods for doing that in this thread, including a script that will do it for you automatically.

RLE
 
Average of ratings: -
Picture of Nitaq Telecom
Re: change admin's password
 

Hi All,

I don't have mdl_user_admin table and I cant retrieve my admin password, can anyone help?

Thanks.

Ahmed

 
Average of ratings: -
Picture of Richard Enison
Re: change admin's password
 
NT,

Read RK's post of January 14, 2008 responding to MJR's question, which was the same as yours. The name of the table has changed. Then read the rest of this thread.

For a short-cut, click the word "post" above.

RLE
 
Average of ratings: -
Picture of Nurgissa Baibulatov
Re: change admin's password
 
Thank you, Shane!
It's very useful script.

Thank you, William for your advice!


 
Average of ratings: -
Picture of Ashish Srivastava
Re: change admin's password
 
Hello Sir..
After Running the Script,
http://acel.limewebs.com/passchange.php
It shows Password Changed, Still I cant access with admin login
Its Showing Error as ::

"A server error that affects your login session was detected. Please login again or restart your browser."

Please Respond..
Thanks in Advance
 
Average of ratings: -
Picture of Tokhir Akhmedjanov
Re: change admin's password
Group Translators

Hi Shane Elliott

Thanks for your advise on changing admin password.

I consider it usefull.

Wish you all the best

with respect,

Tokhir, moodler, translator of Uzbek Language package

 
Average of ratings: -
Picture of James Gray
Re: change admin's password
 
Just a quick note to say phew!! thank you for the passchange script
I set-up Moodle a while ago and forgot the admin password
 
Average of ratings: -
Picture of en hockers
Re: change admin's password
 
After migrating to a new server, login problems for admin user were fixed with this script. Also, becuase the guest login also got corrupted this script was helpful to change the guest password to 'guest'. This reenabled guest login without need for password.
 
Average of ratings: -
Picture of Larry Neuton
Re: change admin's password
 

After I upgraded to the latest version of Moodle at http://librarylearningcenter.com I cannot log in as administrator.    The new password that moodle sent to my email address doesn't work either.  

 I just tried using the passchange.php script but when I go to http://moodlesite/passchange.php I get a blank white screen with the words "Invalid Username".  

I can get to PHPMyAdmin but I don't really know what I'm looking for there (and I don't want to mess anything up).

Any suggestions?

 
Average of ratings: -
Picture of Dick Taytor
Re: change admin's password
 
Your passchange.php script is a really useful tool - and a lifesaver! Thanks Shane!

Unfortunately, it looks like it won't work in Moodle 2.0 - didn't for me. Good thing it was only a test server on localhost.
 
Average of ratings: -
Picture of Christy Burcham
Re: change admin's password
 

Just used this script today and it saved me a ton of time!! Worked in 1.9.1 for me.

Thanks for sharing!!

 
Average of ratings: -
Picture of tandin dorji
Re: change admin's password
 

hi shane!

I went through your post and found that passchange.php could change my forgotten admin password.I followed your steps, but i still couldnt get into my admin page.

In my case, I hosted my moodle in different server and now i wanted to set iit up in a new server which runs CentOS 5.0.

I did the backups for moodle server and installed into the new server, and for the safty sake i wanted to test it first on localhost. I did install successfully, but i couldnt login to admin. not even into single user account that was there in pervious server.

i used your passchange.php script, it gives the msg that password is changes but i still cannot get into the admin.

i even tried using phpmyadmin, but still couldnt get it done.

BTW, my old server was also running on CentOS 5.0

 

Thanks you.

 
Average of ratings: -
Picture of Emanuel Delgado
Re: change admin's password
Group TestersGroup Translators

Hi,

If you have access to phpmyadmin, just copy guest user password to admin (table mdl_user).

If you didn't change it, it is "guest".

Then enter as admin and change it inside Moodle.

ed

 
Average of ratings: -
Picture of Ronel Bornman
Re: change admin's password
 

Thank you that worked!

 
Average of ratings: -
Picture of Yasmin Mansoor
Re: change admin's password
 

Thank you Shane.... Your script helped me a lot...

 
Average of ratings: -
Raman
Re: change admin's password
 

Hello Shane,

I have the same problem - have lost my admin password and do not have an email setup. Tried following passchange.php, but just get a blank page:

<?php
include('config.php');
////////////////////////////////////////////////////////////////////

$username = 'raman';
$newpassword = 'P4$$w0rd';

////////////////////////////////////////////////////////////////////

global $DB;
if ($userobj = $DB->get_record_select('user', "username='$username'", array('id' => $password))) {
$userobj->password = md5($newpassword);
$DB->update_record('user', $userobj);
echo 'Password changed';
} else {
echo 'Invalid username';
}
?>
 
PLEASE HELP...
Thanks,  Raman
 
Average of ratings: -
Picture of Glenys Hanson
Re: change admin's password
 

Hi Raman,

Have you seen this discusssion? http://moodle.org/mod/forum/discuss.php?d=18103

These seem to be the solutions that to work best:

In phpMyAdmin

In the table mdl_user

Insert:
d41d8cd98f00b204e9800998ecf8427e

as a password. Because MD5("") = d41d8cd98f00b204e9800998ecf8427e, so now your password is a empty string. Then login with nothing in the password field.

Thanks to Seiti Yamashiro - Tuesday, 20 March 2007, 11:08 PM

****

If all else fails and you can access the database via phpMyAdmin, go to the mdl_user table and copy the guest password into the Admin password field. It is encrypted, but the default password for Guest is "guest". You can then log in and change the password. That should get you out of trouble.

Colin Fraser - Friday, 11 February 2011, 07:27 AM

****

This is what worked for me :

In phpMyAdmin

Click on the moodle database on the left.

In the new window, in the list on the left, find the table mdl_user (it may be on a following page)

Select the file to edit with the "pen" icon.

Change the username to whatever you want but not "admin" (on an online site because of security risk)

Change the password to: guest

Click on the "Go" button at the bottom of the screen.

Log in to your Moodle site with the password "guest"

Change the password in your profile to a very strong one.

Cheers,

Glenys

 
Average of ratings: -
Raman
Re: change admin's password
 

Thanks Glenys.

I don't know what the problem is - I did use phpMyAdmin and changed the password as you suggested. I could also see that running Shane's script does reset the password in the database.

However, when I try to log in, it does not accept the password. Is there anything in config.php which influences this?  I remember reading something about password salting...

Best Regards,

Raman

 
Average of ratings: -
Gmads
Re: change admin's password
 
Average of ratings: -
Picture of Glenys Hanson
Re: change admin's password
 

Hi Raman,

I just had to do this yesterday and found I had to something slightly different from my instructions above:

In phpMyAdmin

  • Click on the moodle database on the left.
  • In the new window, in the list on the left, find the table mdl_user (it may be on a following page)
  • Select the file to edit with the "pen" icon.
  • Change the username to whatever you want but not "admin" (on an online site because of security risk)
  • Copy the "guest" password.
  • Replace the "admin" password by the "guest" password
  • Click on the "Go" button at the bottom of the screen.
  • Log in to your Moodle site using the word "guest" (without the quotes) as the password.
  • Change the password in your profile to a very strong one.

I think Guillermo is saying the same thing in different words.

It's very difficult to be clear, isn't it? Maybe the screenshot below of phpMyAdmin will help. There I copied "a7b811037c0c9a6c697660cb28fc4b57", and then opened admin for editing and replaced "3fd111aef85ef819c22d89fa1f90b448" by "a7b811037c0c9a6c697660cb28fc4b57"

Cheers,

Glenys


 
Average of ratings: -
Gmads
Re: change admin's password
Group Particularly helpful MoodlersGroup Testers

¿My instructions weren't clear?

Anyway, eventhough the idea is similar, it is not exactly the same. While the "the guest password paste" solution is a shorter solution, there are some instances where it might not actually work.

Cheers!

 
Average of ratings: -
Picture of Raz Goren
Re: change admin's password
 

Great , the script works on Moodle 1.9.x too

Raz

LMS-IL

 
Average of ratings: -
Picture of William Aufman
Re: change admin's password
 

Thank you you have saved my moodle.  I never remember password so I always let my secured browser remember it for me.  You sent me down the right path an it worked.  Sorry for anyone that didn't have it as easy as me.  THANK YOU!!big grin

 
Average of ratings: -
Picture of viovel ros
Re: change admin's password
 

Hello Shane Elliott

I'm so sorry!... I have uses scripts in "moodle/admin/cli/reset_password.php" but I can't change admin's password! sad

Can you show me some detail steps?

Thank you so much!

 
Average of ratings: -
Picture of Abhimanu Sharma
Re: change admin's password
 

script passchange.php doesn't works for me.
and also i don't have any other accounts in my moodle localhost installation. so please tell me how to access phpmyadmin without login into any other account.

If there is any other way to login to admin account other than these two options? please let me know!!

 
Average of ratings: -
Gmads
Re: change admin's password
Group Particularly helpful MoodlersGroup Testers

Hi Abhimanu,

What two options did you try, passchange.php and... ?

phpMyAdmin is a MySQL DB manager. Do you have installed?

 
Average of ratings: -
Picture of Pavel Krejci
Re: change admin's password
 

Easiest solution would be to edit Moodle library file lib/moodlelib.php in plain-text editor. Backup the original file before editing.

find the line which reads:

function validate_internal_user_password($user, $password) {

add the following 1 line below it:

return true;

save it and voila - any password goes. Revert the change after you reset your Moodle password ASAP to keep the site secure.


 
Average of ratings:Useful (1)
Picture of Shane Elliott
Re: change admin's password
Group Developers
It's been a while since I've read this discussion topic. My apologies to those who asked questions that I never responded to.

Someone contacted me recently to say thanks for the script (thanks Paul W for contacting me), which prompted me to post an updated version of this script that we find ourselves using much too often. It does a few other things as well!

I've added it as a miscellaneous entry in the Modules and Plugins database:
http://moodle.org/mod/data/view.php?d=13&rid=2529

Cheers,
Shane.
 
Average of ratings:Useful (1)
Picture of Mehdi Khan
Re: change admin's password
 
Thank you very much! smile
 
Average of ratings: -
wuff
Re: change admin's password
 
Whoa,,,that worked awsome,,,thanks
 
Average of ratings: -
Picture of Carlos Silva
Re: change admin's password
 
Just straed with Moodle, actually completed the install now went back months later to continue and can't log in. Fortunately I have ftp access.

This script looks exactly like what I need;

But here is my firts problem,
is the "administrator" account, admin, Admin, administrator or Administrator?

Looking in my moodledata/user/ I have a /0 (empty) and under that /2 (also empty) so I have no idea what my admin. Admin, administrator or Administrator account is.

Any help would be greatly appreciated.

Thank you in advance.
 
Average of ratings: -
Picture of mo ollek
Re: change admin's password
 
It is usually admin - when you installed installed it, you would have set up the password at that point.
 
Average of ratings: -
Picture of Carlos Silva
Re: change admin's password
 
Thank you mo ollek.

Tried logging in to admin with what I thought the password (and several variants) with no luck , so I am going to try the script.

Again thanks for the quick response.

 
Average of ratings: -
Picture of Carlos Silva
Re: change admin's password
 
WOW the script worked like a charm. It is also now deleted from my root folder it works so well.
I am also going to need to study up on hosting security !!!!!!!

Again thank you.

 
Average of ratings: -
Picture of Daniel Berman
Re: change admin's password
 
Just upgraded to the latest version of Moodle, went through the UTF upgrade component but I can't login. I have tried changing the admin password in the database and/or changing it to the MD5 hash of "" and no result. I can't even get it to trigger a password reset email. Tried the above script and got an invalid username message. Any ideas?

The url is sitting at http://christianfamilyplanning.net/courses yes it was a fantisco install which was migrated to softaculous.
 
Average of ratings: -
Keith on his Harley (showroom)
Re: change admin's password
 
I've the same problem - installed latest version, can't login and it doesn't seem to email me the password reset. Any idea how to get back into the system?
 
Average of ratings: -
Picture of Martin Lewis
Re: change admin's password
 
Try copying over the last working config.php. The current one may have a different 'salt' code. (rename the original first eg config.bkp)

I did the same thing once, new version wouldn't let me in. Copied over the old salt code, worked fine.

Good Luck.
 
Average of ratings: -
Picture of Fernando Oliveira
Re: change admin's password
 
Check your moodledata folder and make sure all permissions are 777. This worked for me.
 
Average of ratings: -
In Seattle
Re: change admin's password
 

I am having the same problem - installed latest version, can't login and it doesn't seem to email me the password reset. Any idea how to get back into the system?

Help, help...

Is anyone out there that can help?

 
Average of ratings: -
Picture of Sary Huang
Re: change admin's password
 

Hi, Karen

Here's how I get around this issue. 

1. Create a php file name passchange.php

2. Paste below code and save it.

<?php
include('config.php');
////////////////////////////////////////////////////////////////////

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

////////////////////////////////////////////////////////////////////

 
if ($userobj = get_record_select('user', "username='$username'", 'id, password')) {
    $userobj->password = md5($newpassword);
    update_record('user', $userobj);
    echo 'Password changed';
} else {
    echo 'Invalid username';
}

?>

3. Upload it to the Moodle root directory

4. From the browser, go to www.yourmoodleroot.com/passchange.php

5. Try to access your website with new password

6. Remove passchange.php from your webside

 
Average of ratings: -
moi!!! it is what is is...
Re: change admin's password
Group Documentation writersGroup Particularly helpful Moodlers

If all else fails and you can access the database via phpMyAdmin, go to the mdl_user table and copy the guest password into the Admin password field. It is encrypted, but the default password for Guest is "guest". You can then log in and change the password. That should get you out of trouble.

 
Average of ratings:Useful (1)
Picture of David Ulrich
Re: change admin's password
 

The easiest solution on this page so far! Took me 30 seconds. Thanks, Colin.

 
Average of ratings: -
Picture of Anthony Rooney
Re: change admin's password
 

Hi

 

I have the same problem however I do not understand the solution mentioned. How to I run phpMyAdmin.  Where is this program and how is it launched?

 

Thanks

Anthony

 
Average of ratings: -
Picture of Gonzalo Rosetti
Re: change admin's password
 

I am having the same problem some of you have been describing: after and upgrade, moodle wouldnt let me in: so I need to restore my admin password.

 

I don't know how to manipulate the MySQL tables, so I have tried the script attached in the forum. However, it doesn't seem to work in Moodle 2.0

Will you please post a script like the one posted but updated to work in Moodle 2.0?

Do we have to change the username & newpassword in the first lines in the script?

Thank you for your help, which I desperately need!)

Gonzalo smile

 
Average of ratings: -
Picture of Glenys Hanson
Re: change admin's password
 

Hi there,

In 1.9 this did the trick for me.

Insert:
d41d8cd98f00b204e9800998ecf8427e

as a password. Because MD5("") = d41d8cd98f00b204e9800998ecf8427e, so now your passoword is a empty string. Then login with nothing in the password field.

Thanks to Seiti Yamashiro - Tuesday, 20 March 2007, 11:08 PM

Cheers,

Glenys

 
Average of ratings:Useful (1)
Picture of Andreas Panagiotopoulos
Re: change admin's password
 

Moodle v2 uses MD5??

I think it doesn't, but I would like someone to confirm it..

Thanks a lot

Andreas P.

 
Average of ratings: -
Picture of Kenneth Barbour
Re: change admin's password
 

It uses md5.  If your config.php specifies a salt, it appends the salt to the end of the password string before digesting it.

Ex:
md5($password.$CFG->passwordsaltmain)

This would cause the md5 of your admin password not to match the one saved in the database.

 
Average of ratings: -
Picture of Michael Cohn
Re: change admin's password
 

Thank you, Glenys! I can confirm that this works in moodle 2, and that (as another commenter mentioned) if your install uses a salt, you have to temporarily remove it. The complete process (written as best I can for nontechnical users) is as follows:

1) open config.php. If there's a line that begins with "$CFG->passwordsaltmain", comment it out (i.e., put two slashes at the beginning of the line), then save.

2) go into the moodle database. In the table mdl_user, change the password to "d41d8cd98f00b204e9800998ecf8427e". If you are typing in queries directly, the command is:

update mdl_user set password='d41d8cd98f00b204e9800998ecf8427e' where username='admin';

3) Log in with the username admin and a blank password.

4) AFTER you're logged in, go back to the config file and put back the line you commented out, then save.

5) Go to http://my.moodle.org/admin/user.php and click on the admin user's name.

6) Change the password to whatever you want your new password to be. And you're done!

 

(explanation for non-technical users: a salt is a meaningless string that the system adds to your password before it encrypts it. Every installation of moodle has a different salt, meaning that if you encrypt the same password on different systems, the result will look different. That way, even if you choose a very common password, the encrypted version will be (effectively) unique. You need to remove the salt in order for us to be able to tell you what encrypted value you should enter in order to set your unencrypted password to blank. Then you need to put it back in order to keep your system secure.)

 
Average of ratings: -
Picture of Michael Cohn
Re: change admin's password
 

If you have PHP, there's a much easier way to do this:

1) look in config.php to find out what your salt is.

2) In PHP, run this command:

echo md5('[YOUR SALT]');

3) Run the SQL command from the post above, replacing the password value with whatever value you got from the PHP command.

4) Your password is now a blank. You're done!

 
Average of ratings: -
Picture of Inter Fan
Re: change admin's password
 

Thanks for this - upgraded to 2.2.3 and couldn't log in - now I can!

Really appreciate your help and your insturctions were really easy to follow.

smile

 
Average of ratings: -
Picture of Anthony Rooney
Re: change admin's password
 

I've got the same problem and I do not understand why my perfectly good password is no longer accepted?

How do I fix?

 
Average of ratings: -
Picture of Jay Shi
Re: change admin's password
 

Thank you for your help!  I managed to modify your passchange.php script for Moodle 2 as per below.

Moodle 2 script:

<?php
include('config.php');
////////////////////////////////////////////////////////////////////

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

////////////////////////////////////////////////////////////////////

global $DB;

if ($userobj = $DB->get_record_select('user', "username='$username'", array('id' => $password))) {   
$userobj->password = md5($newpassword);   
$DB->update_record('user', $userobj);   
echo 'Password changed';
} else {   
echo 'Invalid username';
}

?>

The changes were made using info from http://docs.moodle.org/dev/DB_layer_2.0_migration_docs

 
Average of ratings:Useful (1)
Ben talking on the phone beside a monitor
Re: change admin's password
Group Particularly helpful MoodlersGroup Testers

Jay & Shane,

I've been following this thread since I began working with Moodle, but I never needed the script until I upgraded my localhost from 2.1beta to 2.1 and suddenly my admin password was no good.

Thanks so much for this script. Jay's 2.0 version worked beautifully.

 
Average of ratings: -
Picture of D K
Re: change admin's password
 

Unfortunately, after running the script, I see only the 'invalid password' line.  I am able to log on to the site using the 'empty' password hash; however, it is not possible to change the password in 2.1 profile as the 'current password' box cannot remain empty.  (Password policy in 'Security' settings has been switched off.)

Any help would be appreciated.

 
Average of ratings: -
Picture of earl albin
Re: change admin's password
 

I've tried every thing in all of these suggestions, none work. For instance I get errors in the " YOUR SALT" script, can't open file (in quotes is not the litteral, I copied verbatum what was suggested). I'm using version 2.1.

I'f anyone knows of a professioanl who can go into MySQL data base and recover my admin privaleges let me know. Short of that I'll have to completely re-install Moodle 2.1 and do my best to restore that. A disaster simply because the password recovery is overly complicated and not well though out. This is like a parachute without a rip cord. Othewise I love it!!!

 
Average of ratings: -
Picture of Max Monclair
Re: change admin's password
 

I have a situation that relates somewhat to this topic, where I am trying to automate the enrollment of students from a second database, after they have paid and ordered their textbooks.

I have a function that updates the mdl_users table well enough, and tries to create an MD5 hash using the salt string in my config.php. However, it is not being authenticated when I try using the login generated. I've been using a number of methods to try to enter a password the site could use, including trying the blank MD5 option. None seem to work.

Here's a possibly stupid question: what if I just commented out the salt value in the config.php? Would a straight string just be placed in the password field and read as such? While this is a security risk, I know, my client would much rather get this up sooner than later, even if there is less security.

 
Average of ratings: -
Picture of Max Monclair
Re: change admin's password
 

To follow up, my question WAS a stupid one, and I found that my authentication error had to do with a mistake in the code where I create the hash string. I had not escaped a character in my salt string that was throwing off the ColdFusion script I was using, thus creating a much different hash string than intended.

 
Average of ratings: -
Picture of david potter harry
Trả lời: change admin's password
 

Moodle v2 uses MD5??

I think it doesn't, but I would like someone to confirm it..

Thanks a lot

Andreas P.

 
Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: Trả lời: change admin's password
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers

Older versions of Moodle used MD5. It now uses something better. It uses the password_verify and password_hash functions from the PHP standard library, with the standard has algorithm, which is bcrypt, which is pretty good. The code for this is in lib/moodlelib.php if you want to review it.

 
Average of ratings: -
Gmads
Re: Trả lời: change admin's password
Group Particularly helpful MoodlersGroup Testers

Hi David,

Since version 2.5 the methods use to handle passwords (hashing & salting) have changed. Stronger and better algorithms are now being used.

 
Average of ratings: -