Convert database of Mysql to latin in utf-8

miércoles, 4 de abril de 2007

First execute mysqldump and get a copy of you databa

$ mysqldump --user=name --password=password --default-character-set=latin1 
--
skip-set-charset dbmysql > dbmysql.sql

Second execute the comand sed this comand help us for convert the database
$ sed -r 's/latin1/utf8/g' dbmysql.sql > dbmysql-utf8.sql 


Third droped and create the database with charset utf-8
$ mysql --user=name --password=passwd --execute="DROP DATABASE dbmysql;
CREATE DATABASE dbmysql CHARACTER SET utf8 COLLATE utf8_general_ci;
"


And the end put the new database-utf8 in mysql.
$ mysql --user=name --password=passwd --default-character-set=utf8 
dbmysql
< dbmysql-utf8.sql

Well, I hope help you.

Fuente: http://textsnippets.com/posts/show/84

0 comentarios: