forgot the moodle admin password of my local moodle server

1k Views Asked by At

forgot the moodle admin password of my local moodleyour text server i am using the version 4.1 moodle i know the username but unfortunetly forgot the password my local moodle server. i have tried to forgot the password i havent give the smtp address so i cant recieve the mail of reset password

enter image description here

login to moodle server but i have forgot the passwqord so i am not able to login

3

There are 3 best solutions below

2
Russell England On

You can reset the password from the command line

php admin/cli/reset_password.php --username=admin --password=newpassword
0
KSankar On

Here is a more hacky approach that works provided you have access to the database.

For context, Moodle uses the PHP function password_hash() to generate a password hash for users. The basic idea is that you want to use this function in a plain PHP file outside of Moodle to output a password hash of a new password. This hash is then manually saved in the password field in your mdl_user table using your database client and your new password used to login to the site.

PHP File:

<?php
echo password_hash("new_password", PASSWORD_DEFAULT);

Example output of password_hash:

$2y$10$NCC4PVZ1kTRg4bT21yEl2eUVWMf3lkbYtczTn8vB53qNwTqtN9jwS

0
haris.doku On

It happens to the best of us, me included, what I did was the following:

  1. Access Moodle's DB
  2. Locate the user table
  3. Go to the "username" column
  4. Find the "admin" user
  5. Use php's password_hash function
  6. Update the password in your DB
  7. Most importantly save your changes

Now you should be able to access your local Moodle installation using the new password.

Always keep records of your passwords to avoid tiresome issues like this one.