Admin Login Failure after Moodle Module Install

Admin Login Failure after Moodle Module Install

by Tony Gordon -
Number of replies: 3

This isn't a question, but a description of a major dilemma faced after our Moodle 2.3 instance became inaccessible after an attempted module install.

The back story: we have an NSF project based on a blended delivery model using Moodle.  Upgraded the core to 2.3 a few weeks back.  Some modules installed were lost during the upgrade (questionnaire, Exabis, Abode Connect).

The team asked for the "old" modules to be added to the new install.  So I dowloaded the latest versions, and added them last night.

The problem: I logged out and then tried to login a few hours later.  I then discovered that my login didn't work.  So I tried the password recovery route ... neither the username or the email route would work: both ... both kept returning an error "Incorrect sesskey submitted, form not accepted!"

Thinking that I had corrupted my password, I was able to access the SQL database using PHPmyadmin, and navigated to the mdl_user table.  I replaced the password with a newly generated MD5 hash ... and it didn't work!

Tried changing the password for other admin users ... no joy.  Even tried changing Guest permissions ... didn't work.

So I was now totally locked out of a moodle instance with all the course materials ... and the last time the courses were backed was months ago (moral of the story: backup all courses before you do a thing!)

Solution: 

Step 1: create a new instance of moodle, complete with its own moodledata directory and SQL database. Test the install to make sure it is working.

Step 2: Using PHPMyadmin, open the database for the OLD instance and the NEW instance (dual monitors helps ... needless to say, I was in the middle of a conference, and so had to use a laptop ... not recommended!).  Compare the table definitions from both instances, and delete all tables in the OLD instance that do not appear in the NEW database.  [At the conclusion of this process, the OLD database and the NEW database have the same table definitions.  Any mods/blocks/etc. tables that were installed in the OLD database will be deleted.]

Step 3:  Backup the OLD database with the EXCEPTION of all the mdl_user related tables (there are about 5 of them) as a SQL database.

Step 4: Using Myphpadmin, navigate to the NEW database.   Clear every table of its contents with the EXCEPTION of all the mdl_user related tables. Do NOT delete the tables, just empty the content (This takes a lot of time!).

Step 5: Using Myphpadmin, import the OLD database backup to the NEW database.  This will bring in all the data from the old database with the exception of the user information.

Step 6: Locate the Moodledata directory in the old instance.  Copy the entire Moodledata directory into the new Moodledata instance.

Step 7: Run the new instance, and login using the credentials used to create the new instance ... if you are fortunate, your site will be up and running.

Step 8: All user data will be lost, so will have to reimport or recreate user accounts.

There may well be an easier way to do this, but I couldn't find it after much searching on a lot of Moodle forums!

As mentioned earlier, if you regularly backup courses, this would not have been a problem.

Average of ratings: -
In reply to Tony Gordon

Re: Admin Login Failure after Moodle Module Install

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Hmm....

I would have been more interested to track down why the logins stopped working in the first place. I have seen a lot of weird things but never a plugin (especial a non-auth one) breaking logins. I think it was a bit of an assumption without proof.

Did you work through the long list of "I can't log in" checks in the Installation FAQs?
In reply to Howard Miller

Re: Admin Login Failure after Moodle Module Install

by Tony Gordon -

I tried every variation of php login failure recovery, unsuccessfully, followed by 2 or so hours trying to get access using Myphpadmin user credential edits that were suggested in various forums.

In reply to Tony Gordon

Re: Admin Login Failure after Moodle Module Install

by Cory Chamberlain -

We just set up a new server with Ubuntu 12.04 LTS and installed Moodle 2.3 on it. This happened to one of our admin people when setting things up. Has anyone found the exact cause of this or is the first solution above the only option? Personally I don't see the good in going through all that only to still be at risk of it happening again.