Manually change the moodle admin password with acces to phpMyAdmin or create another admin account?

Trufa picture Trufa · May 5, 2012 · Viewed 32.9k times · Source

The password for an admin login in a moodle platform is lost.

I have access to the phpMyAdmin.

I went to the mdl_user table and there I can see or edit this table.

How should I proceed? Can I change the admin encripted password and secret key to a known password or is it simpler to just add an admin user?

How would that be?

Answer

marxjohnson picture marxjohnson · May 10, 2012

Open up Moodle's config.php file, find the line where $CFG->passwordsaltmain is defined, and copy it's value (it's a long string of random characters).

In PHPMyAdmin, run the following query, substituting values as appropriate:

UPDATE mdl_user SET password = MD5(CONCAT('<new password>', '<password salt copied from config>')) WHERE id = <id of admin user>