could not find course/ could not find top level course/ could not find course category
Could not find course category
If you get this error (could not find course category) this basically means the course/s that exist don't have categories in the category table.
Look at the mdl_course table in mysql. Column 2 is the course category. Every course listed (per row) must have a category identified in the table mdl_course_categories.
For example, if you have this as your data
(1, 0, 0, "course name", "course name", "", "summary", 0, "site", 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", "", 1606214720, 1606215795, 0, 0, 0, 1606215383);
You see the course category is zero.
| 1 | Miscellaneous | NULL | NULL | 0 | 0 | 10000 | 0 | 1 | 1 | 1606214720 | 1 | /1 | NULL |
If there is a mismatch, correct it, e.g. by updating the course to belong to the category.
Update mdl_course set category = '1' where format = 'site' and id = 1;
https://moodle.org/mod/forum/discuss.php?d=150439
Could not find top-level course
This means that mdl_course is empty. Type/copy/paste this:
insert into mdl_course (id, category, sortorder, fullname, shortname, idnumber, summary, summaryformat, format, showgrades, newsitems, startdate, enddate, relativedatesmode, marker, maxbytes, legacyfiles, showreports, visible, visibleold, groupmode, groupmodeforce, defaultgroupingid, lang, calendartype, theme, timecreated, timemodified, requested, enablecompletion, completionnotify, cacherev)values
(1, 1, 0, "name", "name", "", "summary", 0, "site", 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, "en", "", "", 1606214720, 1606215795, 0, 0, 0, 1606215383);That should create a course, but you still have to set its category.
insert into mdl_course_categories (id,name,idnumber,description,descriptionformat,parent,sortorder,coursecount,visible,visibleold,timemodified,depth,path,theme ) values (1,"Miscellaneous",1,"Misc",0,0,10000,0,1,1,1606214720,1,"/1",NULL);
select * from mdl_course_format_options;
+----+----------+--------+-----------+-------------+-------+
| id | courseid | format | sectionid | name | value |
+----+----------+--------+-----------+-------------+-------+
| 1 | 1 | site | 0 | numsections | 1 |
+----+----------+--------+-----------+-------------+-------+