Warning: opendir(/vcdata/webroot/manhnd.com/blog.manhnd.com/wp-content/themes/postcard/styles/) [function.opendir]: failed to open dir: Permission denied in /vcdata/webroot/manhnd.com/blog.manhnd.com/wp-content/themes/postcard/includes/theme-options.php on line 39
Convert latin1 to utf8 in MySQL | Mạnh Nguyễn

Oct 22

Convert latin1 to utf8 in MySQL

by ManhND in Linux

Dump DB nguyên bản skip charset

mysqldump -u root -p --opt --default-character-set=latin1 --skip-set-charset testdb > testdb.sql

Sử dụng Sed replate latin1 sang uft8

sed -e 's/latin1/utf8/g' -i ./testdb.sql

Tạo mới DB

mysql>DROP DATABASE testdb;
mysql>CREATE DATABASE testdb CHARACTER SET utf8 COLLATE utf8_general_ci;

Import dump file. Set default charset

mysql -u root -p --default-character-set=utf8 testdb < testdb.sql

Tags: ,

Leave a Reply