Convert latin1 to UTF-8 in MySQL

mysqldump -u root -p –default-character-set=latin1 -c –insert-ignore –skip-set-charset -r dump.sql latin1_dbname
file dump.sql
Non-ISO extended-ASCII HTML document text, with very long lines
iconv -f ISO8859-1 -t UTF-8 dump.sql > dump_utf8.sql
file dump_utf8.sql
UTF-8 Unicode HTML document text, with very long lines
perl -pi -w -e ‘s/CHARSET=latin1/CHARSET=utf8/g;’ dump_utf8.sql
mysqladmin -u user -p –default-character-set=utf8 create utf8_dbname; või mysql käsurealt: CREATE DATABASE `utf8_dbname` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
mysql -u user –max_allowed_packet=16M -p –default-character-set=utf8 utf8dbname < dump_utf8.sql

Leave a Reply