Database migration: Difference between revisions
Fast conversion |
mNo edit summary |
||
| Line 19: | Line 19: | ||
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): | 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): | ||
* your Moodle site must use only one encoding (eg. all courses use a latin1/ISO-8859-1 language) | |||
* put your Moodle site off line | * put your Moodle site off line | ||
* export your data from old server (MySQL 4.0.x uses ISO-8859-1 encoding by default): | * export your data from old server (MySQL 4.0.x uses ISO-8859-1 encoding by default): | ||
| Line 24: | Line 25: | ||
mysqldump -h ''<old mysql host>'' -u ''<moodle db user>'' -p ''<old moodle db name>'' > dbdump.sql | mysqldump -h ''<old mysql host>'' -u ''<moodle db user>'' -p ''<old moodle db name>'' > dbdump.sql | ||
* upgrade | * upgrade your MySQL server | ||
* upgrade your Moodle; remeber to install UTF-8 version of all require languages | |||
* create your new Moodle database and set appropriate privileges | * 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) | * re-import your data (MySQL 5.x uses UTF-8 encoding, but your data is ISO-8859-1 encoded) | ||
| Line 40: | Line 42: | ||
update mdl_config set value='true' where name=unicodedb; | 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. | For a medium size database, migration require only 3-4 minutes. | ||
Revision as of 07:24, 31 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):
- your Moodle site must use only one encoding (eg. all courses use a latin1/ISO-8859-1 language)
- 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 your MySQL server
- upgrade your Moodle; remeber to install UTF-8 version of all require languages
- 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.