Difference between revisions of "WikiMysqlMigratie"

From Cncz
Jump to: navigation, search
m
 
(5 intermediate revisions by one other user not shown)
Line 10: Line 10:
 
optie bij mysqldump. Dus bijv.:
 
optie bij mysqldump. Dus bijv.:
 
[/nl]
 
[/nl]
 +
[en]
 +
Migrating a mediawiki database from a mysql4 to a myslq5 server it may happen that different character
 +
encodings result in incorrectly displayed page titles in the migrated wiki and/or broken links to titels
 +
containing accented characters. During the migration the unwanted conversion can take place during the
 +
dump and during the import. So one should take care at both phases. In the mysqldump one has to
 +
use the --default-character-set=latin1 option, so:
 +
[/en]
  
/usr/local/mysql-4/bin/mysqldump --default-character-set=latin1 --allow-keywords --quote-names  --add-drop-table  -p -h localhost database >database.sql
+
/usr/local/mysql-4/bin/mysqldump --default-character-set=latin1 --allow-keywords --quote-names  --add-drop-table  -p -h localhost database >database.sql
  
 
[nl]
 
[nl]
 +
Het resultaat is een dump met utf8 data maar met table create statements waarin nog
 +
default charset en collate op latin1 staat. Als je deze vervolgens zomaar importeert in een mysql5 server
 +
met default charset en collate utf8 vindt er alsnog een conversie plaats. Om dit te voorkomen
 +
substitueer je in de sql dump "=latin1" door "=utf8".
 +
Vervolgens kun je het sql file importeren.
  
 
[/nl]
 
[/nl]
 +
[en]
 +
The result is a dump with utf8 data but with table create statements still using
 +
latin1 for the default_charset en collation. If one would import this data in a mysql5
 +
server the data will be converted which will lead to wrong titles /and/or broken links.
 +
To avoid this replace globally in the sql dump "=latin1" with 'utf8". 
 +
[/en]
 +
 +
cat database.sql | sed -e "s/CHARSET=latin1 COLLATE=latin1/CHARSET=utf8 COLLATE=utf8/g' | mysql  -h localhost -u root database -p
 +
 +
[[Category:Wiki]]

Latest revision as of 13:35, 13 November 2009

Mediawiki mysql migration

Migrating a mediawiki database from a mysql4 to a myslq5 server it may happen that different character encodings result in incorrectly displayed page titles in the migrated wiki and/or broken links to titels containing accented characters. During the migration the unwanted conversion can take place during the dump and during the import. So one should take care at both phases. In the mysqldump one has to use the --default-character-set=latin1 option, so:

/usr/local/mysql-4/bin/mysqldump --default-character-set=latin1 --allow-keywords --quote-names  --add-drop-table  -p -h localhost database >database.sql

The result is a dump with utf8 data but with table create statements still using latin1 for the default_charset en collation. If one would import this data in a mysql5 server the data will be converted which will lead to wrong titles /and/or broken links. To avoid this replace globally in the sql dump "=latin1" with 'utf8".

cat database.sql | sed -e "s/CHARSET=latin1 COLLATE=latin1/CHARSET=utf8 COLLATE=utf8/g' | mysql  -h localhost -u root database -p