Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 285
Trufa Avatar asked May 05 '12 20:05

Trufa


People also ask

How do I change my admin password in Moodle?

Navigate to the Admin User link towards the top right side of the Moodle site. Click Edit profile in the Settings section of the left. In the General settings of the Admin User Section, enter the new user name and/or password. After the New Username and Password are entered click Update Profile.

Where is the login and password stored for access to the Moodle database?

Database method If you do not have command line access, but do have access to the database, you can modify a password there. Passwords for all users, including admin, are stored as cryptographic hashes in the table mdl_user.

How do I reset my Moodle password?

You can reset your password by entering EITHER your username OR your email address below, then clicking the Search button. If your account can be found, an email will be sent to your email address with a link to reset your password.


5 Answers

only tested on Moodle 2

You can reset any user password from command line. In your Moodle root:

php admin/cli/reset_password.php

For dev prod environment you may also want to disable the password policy check (so you can enter a small and quick to type password). Edit reset_password.php and comment:

// if (!check_password_policy($password, $errmsg)) {
// cli_error($errmsg);

// }

like image 186
Jerome Mouneyrac Avatar answered Nov 11 '22 18:11

Jerome Mouneyrac


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>
like image 28
marxjohnson Avatar answered Nov 11 '22 19:11

marxjohnson


ANOTHER, MORE QUICK AND EASY WAY TO GENERATE A NEW MD5 HASH PASSWORD:

  1. Go to http://www.miraclesalad.com/webtools/md5.php and create a new password like... wintersnow123~ (it will look like this: "003df036e1a99aad3eaba7c3ca46723d" without quotes).
  2. Copy the md5 hash password generated from the word you submitted (it's easy) and be prepared to paste it.
  3. Using phpMyAdmin, log into your MySQL database.
  4. Navigate to the user table (for Moodle, it's called "mdl_user") and browse the data.
  5. When you find the "admin" user account, click on edit, and paste in the new password you copied in Step 2 ("003df036e1a99aad3eaba7c3ca46723d"). (Into the password field.) This will replace what you had previously.
  6. Try logging in with your admin user account and the new password (Password: wintersnow123~)
like image 44
Sandi Laufenberg-Deku Avatar answered Nov 11 '22 17:11

Sandi Laufenberg-Deku


You could just check the sourcecode and see how the hash is calculated. You could then make a new hash with your new password with their hashing-function.

I checked the source-code and depending on the configuration, its hashed with md5 or sha1. So check your config and make a hash of your own.

// From the sourcecode:
if ($this->config->passtype === 'md5') {   // Re-format password accordingly
      $extpassword = md5($extpassword);
} else if ($this->config->passtype === 'sha1') {
      $extpassword = sha1($extpassword);
}
like image 38
Zombaya Avatar answered Nov 11 '22 17:11

Zombaya


HOW TO CHANGE THE PASSWORD USING MD5 HASH:

  1. Log into phpMyAdmin. cPanel hosting will have a database utility called PhpMyAdmin within the cpanel. If the Moodle is installed on a non cPanel hosting, contact the hosting company for information on how to edit your database on the server. For more information on logging into PhpMyAdmin, please see the article on "How do I manage a MySQL database in PHPMyAdmin in my control panel (cpanel)?".

  2. In PhpMyAdmin, find the table called mdl_user and select it. Since Moodle has many tables, the mdl_user table may be on the second page. Select the second page. Click the mdl_user table.

  3. After selecting the table, find the table row for the user that is being edited. Click the Edit link with the pencil icon.

  4. There will be a series of characters and numbers in the password field. This is an encrypted password so it cannot be viewed in the database. Replace the encrypted text with the new password for the login.

  5. Next, in the drop down menu to the left, select MD5 then click Go.

This can also be done for the Email address and the Username. The Email and the Username do not need the MD5 hash.

like image 28
Omprakash Patel Avatar answered Nov 11 '22 19:11

Omprakash Patel