MYSQL convert collation

1. Dump erstellen
mysqldump –user=username –password=password –default-character-set=latin1 –skip-set-charset dbname > dump.sql

2. Dump anpassen
– runterladen
– replace: charset: latin1 zu utf8
– replace: collation: latin1_… zu utf8_unicode_ci
– Datei mit utf8-encoding speichern
– hochladen

3. Neue DB mit richtiger collation erstellen/setzen

4. Importieren in neue DB
mysql –user=username –password=password –default-character-set=utf8 dbname < dump.sql

 

#### Alternativ ####
mysqldump –user=username –password=password –default-character-set=latin1 –skip-set-charset dbname > dump.sql
chgrep latin1 utf8 dump.sql (or when you prefer sed -i „“ ’s/latin1/utf8/g‘ dump.sql)
mysql –user=username –password=password –execute=“DROP DATABASE dbname; CREATE DATABASE dbname CHARACTER SET utf8 COLLATE utf8_general_ci;“
mysql –user=username –password=password –default-character-set=utf8 dbname < dump.sql