I have a database in which the stored data are encoded in GBK. Now I want to make a full dump of it and make the dump file in utf8. This way I can convert the whole database from GBK to utf8. The mysqldump utility seems the right way to go and I just looked into the mysqldump documentation http://dev.mysql.com/doc/refman/5.5/en/mysqldump.html#option_mysqldump_set-charset and it seems it uses the utf8 character set. So my question is can I just go with
mysqldump mydatabase > dump.sql
will that do the work for me, will mysqldump automatically convert my GBK database to utf8 for me? And since all the tables used to have a bgk character set set originally, if I want to import the dump file back into another utf8 database, will that work as well?
In mysql charset are assigned on many levels (connection, table, field, ecc).
Assuming that all this levels in the old database are with charset GBK, and all this levels in the new database are with charset utf8, you just have to substitute the charset declaration for each level.
Imagine that this is a portion of the dump file dump.sql
what you need is to transform it into
you could do this with sed
now the file is ready to be correctly imported into an utf8 database