Security and privacy

reset admin password?

 
Picture of Rachel Horst
reset admin password?
 

Hi there,

I can't believe it, but I seem to have forgotten my admin password. The email reset does not ever send an email. Can someone walk me through how to reset the password through the php? I am using the eguru theme... Does that change anything. I would so very much appreciate some HELP!!!!!


Thanks in advance!

 
Average of ratings: -
Picture of Emma Richardson
Re: reset admin password?
Documentation writersParticularly helpful MoodlersPlugin developers

You would need access to the server or the database.  If you google reset moodle admin password, you will find ways to do it.

 
Average of ratings: -
Picture of Puvikanth Sundaralingam
Re: reset admin password?
 

Hi,

1. Login to your moodle database and find the user table mdl_user (moodle ver. 3.3)

moodle user table

2. which admin password is stored using php function 'password_hash' so run the following code with your desired password (I have used 'test' as password).

<?php
             $pass=password_hash("test", PASSWORD_BCRYPT);
              echo "password: " . $pass;
?>

output:

user password

3. copy the password and update the table with copied password.

update password

 that's all now login with the password you used in php encryption.


Thank you.

 
Average of ratings: Useful (2)
Picture of Tomasz Muras
Re: reset admin password?
Core developersPlugin developersPlugins guardiansTranslators

This should also work:

UPDATE mdl_user SET password=MD5('NEW_PASSWORD') WHERE username='admin';

On the next login Moodle will convert from insecure MD5 hash to the proper one - so log in straight away.

 
Average of ratings: Useful (3)
Picture of Leonel Felipe Morales Avella
Re: reset admin password?
 

Excelent, this solution works perfectly!

 
Average of ratings: -
Picture of Lahiru S Ranasinghe
Re: reset admin password?
 

Puvikanth Sundaralingam thank you very much this worked. I'm a little bit new to this moodle this and community here is really helpfull.

 
Average of ratings: -
Picture of Adam Jenkins
Re: reset admin password?
Plugin developers

Hmm, generating your own bcrypt or MD5 hash and then updating the user table in the sql database is kind of the long way around. If you're already at a command prompt, a simpler method is to use the script designed for that purpose:

sudo -u apache /usr/bin/php admin/cli/reset_password.php

You may need to change the word apache above to say "www-data" (Ubuntu) or "httpd" (CentOS) or something depending on your server. But basically, this script allows an admin to reset any password... 

Hope this helps

 
Average of ratings: Useful (3)
Picture of Sofia Rehan Ramli
Re: reset admin password?
 
Hi,


Would this work for standalone Moodle? Where should I write this command?

 
Average of ratings: -
Picture of Chris Baldwin
Re: reset admin password?
 

Hi Sofia

Coming to your question a bit late, but for the benefit of others - this is back end access to the server - if you don't have that, you can ask your hosting company to help you.

HTH

Chris

 
Average of ratings: -