Help reset admin password

Help reset admin password

by Raman Joshi -
Number of replies: 12

I have installed version 1.9 of moodle and have lost the admin password.

I have gone through various postings here and found resetuser.php and put it up in the root directory. It runs OK  - seems to retrieve the admin user record and change the password - I added a couple of "echo"s in STEP 4 and it shows the following:

Step 4:
'21232f297a57a5a743894a0e4a801fc3' is old password from database 
Password reset for 'admin' to password
21232f297a57a5a743894a0e4a801fc3

However, when I enter user id & password on the login screen, nothing happens. Looks like it does not accept the password.

I have attached my edited copy of resetuser.php

What to do next?  

Thanks & Regards,

Raman

Average of ratings: -
In reply to Raman Joshi

Re: Help reset admin password

by Andrea Bicciolo -

Do you have direct access to your Moodle database with a GUI ? If yes, you can modifiy the password editing the field "password" of table "mdl_user" directly from the GUI Interface (please note the table prefix "mdl" may be different according to your setup). For example if you are running MySQL, you could use phpmyadmin to edit the user's password. Make sure to use the function MD5 when editing the password field.

In reply to Andrea Bicciolo

Re: Help reset admin password

by Raman Joshi -

Thanks Andrea.

I do not have myphpadmin installed. I am not a 'techie' anymore so was not sure of what is involved in setting up myphpadmin.

I also read somewhere about password salting and tried commenting out the following in config.php

// $CFG->passwordsaltmain = '}z1:jct^fT/Wdn.{J}O8s0~km#,Z*C';

Has not helped.

Any guidance on how to set up myphpadmin?

Thanks & Regards,

Raman

In reply to Raman Joshi

Re: Help reset admin password

by J C -

Hi Raman,

I think Andrea is referring to using your hosting company's cPanel or similar interfact for PHPMyAdmin. Mostly this is available to you if they are providing MySQL- no need to install anything.

Have you seen this similar discussion?

You may find what you need there- especially the part about assigning a blank pwd. But you'll need to access a database tool first as referenced above.

Hope this helps!

- John

In reply to J C

Re: Help reset admin password

by Raman Joshi -

Thanks John.

I did find the phpMyAdmin on my c-panel and was able to go in and amend the password - still no change sad

Can't get past the log-in screen.  I also tried changing the email address to root@localhost thinking that might show me something - but no luck.

I am at a loss...

Best Regards,

Raman

In reply to Raman Joshi

Re: Help reset admin password

by Guillermo Madero -

Eventhough I'm not familiar with the aforementioned password reset script, I think it isn't working because of the password salting system:

http://docs.moodle.org/19/en/Password_salting

So to regain access to your admin account you need to:

1. Open your config.php file (in the moodle installation directory).

2. Uncomment the passwordsaltmain directive you previously commented out (// $CFG->passwordsaltmain) and save the file.

3. Copy the value of the passwordsaltmain directive: }z1:jct^fT/Wdn.{J}O8s0~km#,Z*C

4. Append the copied value to the text "admin" (i.e. admin}z1:jct^fT/Wdn.{J}O8s0~km#,Z*C) and copy this new string.

5. Go to http://www.md5.net/, paste the previous string at the String box and click on the Generate button.

6. Copy the 32 hex MD5 hash.

7. Go to your server control panel and open PhpMyAdmin.

8. Select your Moodle database.

9. Select the mdl_user table.

10. Select the register of the admin user.

11. Paste the MD5 hash into the password field.

12. Save the changes.

13. Log into your Moodle installation using the password "admin" (without the quotes).

14. Very, very important! Go to the admin profile page and change the password!

Cheers!

In reply to Guillermo Madero

Re: Help reset admin password

by Raman Joshi -

Hi,

I was so sure that this was the answer.  Tried it but no luck.

I am doing something wrong - but can't seem to figure it out sad

I checked MD5 has for 'guest' as the password for guest and it does match with what is stored in the guest user record. However, if I enter user id guest & password guest - it does not log me in. I can access by clicking on the guest access button...

Raman

In reply to Raman Joshi

Re: Help reset admin password

by Guillermo Madero -

But once you login using the guest access button... ¿the MD5 hash in the database remains the same?

In reply to Raman Joshi

Re: Help reset admin password

by Guillermo Madero -

In one of my installations I just tried to login using "guest" as the username and password, and I entered Ok.

In reply to Guillermo Madero

Re: Help reset admin password

by Raman Joshi -

Your instructions were very clear and I did follow them. 

When it did not work, I just checked by generating MD5 hash for guest to confirm that I was doing it correctly - and it matched with what was in the database for guest.

I just found the article in moodle docs that describes salting. According to the following, unsalted MD5 hash would get validated too...

If the unsalted md5 hash of a user's password validates, it is assumed that the salt was set for the first time since the last time the user logged in. The user's password is upgraded, using the salt. The password is salted during the first login after the salt was set in config.php.

Can I reinstall moodle without losing the course data?

Best Regards,  Raman

In reply to Raman Joshi

Re: Help reset admin password

by Guillermo Madero -

Strange, the procedure should have worked fine.

Are you sure you:

1. uncommented the passwordsaltmain line in config.php and saved the file?
2. used the same value you have for the passwordsaltmain directive (without the surrounding single quotes)?
3. tried to login using the password "admin" (or whatever text you might have used at step 4)?
4. are using the correct administrator username?

 

Reinstalling would imply erasing everything, otherwise you are just overwriting the moodle directory, which would not help at all.

-- edit

Is the "auth" field (in the mdl_user table) for the admin user set at "manual"?

In reply to Guillermo Madero

Re: Help reset admin password

by Raman Joshi -

These are the last 3 lines in my config.php

$CFG->directorypermissions = 00777;  // try 02777 on a server in Safe Mode

$CFG->passwordsaltmain = '}z1:jct^fT/Wdn.{J}O8s0~km#,Z*C';

require_once("$CFG->dirroot/lib/setup.php");
 
I did use the correct values and "auth" field is set to manual.
 
What can it be?
Best Regards,
Raman
In reply to Raman Joshi

Re: Help reset admin password

by Guillermo Madero -

Hm, given the fact that you are just starting a new installation, I guess you might restart everything by reinstalling, just as you previously suggested.

Cheers!