breaks during database upgrade saying database table already exists

 If moodle breaks during database upgrade saying "database table already exists", you basically have no choice but to drop that table. My suggestion is to backup the database first:

mysqldump moodle > moodle.sql

Then use vi editor to locate that table and save that code separately. Obviously if the table is empty it doesn't matter.

To find out if the table is empty, go back into mysql and type

use moodle;

select * from tablename;

If it returns zero results, you are in luck, you can just drop the table:

drop table tablename;

But if it contains some stuff, then you have to save it and reload it later using mysqldump and then  mysql.

Something like this:

Assuming you've saved it as shown above

and assuming you've kept only the SQL of that table;

mysql moodle < mytablesql.sql

Anyway, back on to the point.

Once you have dropped the table, go back to the installer webpage, click in the URL bar where it shows the moodle webserver address, and just press Enter. Do not click the "continue" button below the error report as that will send you RIGHT BACK TO THE BEGINNING of the installer.

It should just continue.

In one case I had a nested problem where it was complaining about 3 tables in a row.

Foolishly I assumed that deleting one then reloading would fix it. Nope. You had to delete all three in one shot, otherwise it recreated one, created number 2, couldn't create number 3, failed, restarted, couldn't create number one again because it already existed, etc.

The SQL to load a new database is supposed to say something like

CREATE TABLE IF NOT EXISTS

but it seems the moodle updater/upgrader process just has

CREATE TABLE

hence it barfs if it finds something already existing.


Popular posts from this blog

could not find course/ could not find top level course/ could not find course category

migrating moodle from one server to another

installing moosh to make your life easier