Note: You are currently viewing documentation for Moodle 1.9. Up-to-date documentation for the latest stable version is available here: Database migration.

Database migration: Difference between revisions

From MoodleDocs
(French link)
(Fast conversion)
Line 8: Line 8:


==The migration process==
==The migration process==
=== The right way ===
Since the migration is a process which causes heavy processor and disk load and can take a long time to perform, you should choose when to upgrade carefully. As an indication, Moodle.org had about 3 million bits of text and took 2.5 hours on a very fast dual-opteron server.
Since the migration is a process which causes heavy processor and disk load and can take a long time to perform, you should choose when to upgrade carefully. As an indication, Moodle.org had about 3 million bits of text and took 2.5 hours on a very fast dual-opteron server.


Line 13: Line 15:


The migration process places your Moodle site in [[Maintenance mode|maintenance mode]], so non-admins cannot login. Once the migration process has started, it needs to finish completely before non-admins can login. Your Moodle site will then automatically come out of maintenance mode.
The migration process places your Moodle site in [[Maintenance mode|maintenance mode]], so non-admins cannot login. Once the migration process has started, it needs to finish completely before non-admins can login. Your Moodle site will then automatically come out of maintenance mode.
=== Quick&dirty ===
If, to meet Moodle 1.6 requirement, you are upgrading your MySQL server also, you can apply this strategy (tested converting database from MySQL 4.0.x to 5.0.x):
* put your Moodle site off line
* export your data from old server (MySQL 4.0.x uses ISO-8859-1 encoding by default):
mysqldump -h ''<old mysql host>'' -u ''<moodle db user>'' -p ''<old moodle db name>'' > dbdump.sql
* upgrade you MySQL server
* create your new Moodle database and set appropriate privileges
* re-import your data (MySQL 5.x uses UTF-8 encoding, but your data is ISO-8859-1 encoded)
mysql -h ''<new mysql host>'' -u ''<moodle db user>'' -p --default-character-set=latin1 ''<new moodle db name>'' < dbdump.sql
* MySQL will convert character encoding automatically.
* Now, you must update some data; from a mysql console:
update mdl_config set value=concat(value, '.utf8') where name='locale';
update mdl_config set value=concat(value, '_utf8') where name='lang';
update mdl_course set modinfo=null;
update mdl_course set lang=concat(lang, '_utf8') where length(lang) > 1;
update mdl_user set lang=concat(lang, '_utf8') where length(lang) > 1;
update mdl_config set value='true' where name=unicodedb;
* Update your Moodle config.php to use new server
* Put on line your Moodle site.
For a medium size database, migration require only 3-4 minutes.


==See also==
==See also==

Revision as of 18:15, 30 August 2006

Moodle1.6


Migration and third party modules

If you have third party modules installed, not yet ready yet for the UTF-8 migration, you'll be warned about these on this page. You need to either disable them or install a later version. The migration script can only run once, so if you have problematic third party modules disabled, you will need to use an alternative method such as converting all files to UTF-8 with a database dump.

Language option

If you run your site in one language only, select this option to save a lot of time on the migration. Otherwise, Moodle will figure out how to do the migration for every piece of data, based on the language of the user, course and your Moodle site.

The migration process

The right way

Since the migration is a process which causes heavy processor and disk load and can take a long time to perform, you should choose when to upgrade carefully. As an indication, Moodle.org had about 3 million bits of text and took 2.5 hours on a very fast dual-opteron server.

During the migration process, you'll see a progress bar which updates every now and then. Let it go all the way to 100%. If the migration is interrupted for some reason (browser closed or network failure) don't worry - just wait for a while to make sure the process is finished on the server (you might check processor load, caused by your webserver), and then start the migration again. The process is smart enough to take up where it left off and you'll see messages about this. However, starting the migration script while a former process of the script is still running might cause data corruption.

The migration process places your Moodle site in maintenance mode, so non-admins cannot login. Once the migration process has started, it needs to finish completely before non-admins can login. Your Moodle site will then automatically come out of maintenance mode.

Quick&dirty

If, to meet Moodle 1.6 requirement, you are upgrading your MySQL server also, you can apply this strategy (tested converting database from MySQL 4.0.x to 5.0.x):

  • put your Moodle site off line
  • export your data from old server (MySQL 4.0.x uses ISO-8859-1 encoding by default):
mysqldump -h <old mysql host> -u <moodle db user> -p <old moodle db name> > dbdump.sql
  • upgrade you MySQL server
  • create your new Moodle database and set appropriate privileges
  • re-import your data (MySQL 5.x uses UTF-8 encoding, but your data is ISO-8859-1 encoded)
mysql -h <new mysql host> -u <moodle db user> -p --default-character-set=latin1 <new moodle db name> < dbdump.sql
  • MySQL will convert character encoding automatically.
  • Now, you must update some data; from a mysql console:
update mdl_config set value=concat(value, '.utf8') where name='locale';
update mdl_config set value=concat(value, '_utf8') where name='lang';
update mdl_course set modinfo=null;
update mdl_course set lang=concat(lang, '_utf8') where length(lang) > 1;
update mdl_user set lang=concat(lang, '_utf8') where length(lang) > 1;
update mdl_config set value='true' where name=unicodedb;

  • Update your Moodle config.php to use new server
  • Put on line your Moodle site.

For a medium size database, migration require only 3-4 minutes.

See also