Converting Data from Latin1 to UTF-8

First export the databases which you plan to convert.

$> mysqldump -u root -p123 –default-character-set=latin1 shop > /root/shop.sql

Second, convert the database to utf8

$> sed -e ‘s/SET NAMES latin1/SET NAMES utf8/g’ -i /root/shop.sql
$> sed -i -e ‘s/CHARSET=latin1/CHARSET=utf8 COLLATE=utf8_unicode_ci/g’ /root/shop.sql
$> vi /root/shop.sql (Check the convention is successful or not)

Last step, import the converted database:

mysql> create database shop character set utf8 collate utf8_unicode_ci;
$> mysql –default-character-set=utf8 -u root -p shop < ./shop.sql