Moodle 2.5 Error: “Cannot find data record in database table course_module”

General

You get this error when opening a course, in this case we were using course 33. When entering the course, you get this error message:

“Cannot find data record in database table course_module”

http://moodle.domain/course/view.php?id=33

SOLUTION:

Open MySQL Workbench on the server and then run this query:

select modinfo from mdl_course where id = <courseid>;

Then you should see the course record in the database, you need to clear the modinfo field that appears to force a cache refresh of the course to do this run:

update mdl_course set modinfo='' where id = <courseid>;

Once this is run try accessing the course again, you should find you can get in again.