2

I'm having problems to migrate an utf8 database to another server... Each source and destination table has a "DEFAULT CHARSET=utf8".

I use mysqldump to dump data and mysql < file.sql to import but when in the source table i have "España", in the destination i get "España".

I read some guides, i used --default-character-set=latin1 to export and import, but the problem remains. I also tried a --default-character-set=utf8 to import, but the result is: "Espa", data is truncated to the first occurrence of a multibyte char.

I need help!

Thank you in advance

3 Answers 3

3

It's very important to make sure the client is set to UTF8. Confusingly, it's not the same as setting your database to UTF8. Open /etc/my.cnf and make sure you have default-character-set = utf8 under [mysql] not just under [mysqld]

Now you should be able to pipe UTF8 dumps directly into the mysql client. I also recommend using the option --hex-blob on the mysqldump command as mysqldump is not perfect.

Sign up to request clarification or add additional context in comments.

Comments

1

try

iconv --from-code=ISO-8859-1 --to-code=UTF-8 ./file >file.utf8
mysql --default-charset=utf8 < file.utf8 

If it does not work i advise you to import data then convert it

ALTER TABLE tbl_name CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;

hope it'll help

Comments

0

What is the collation of each table? Sounds to me like the 2nd table is still encoded ISO-8859-1 or similar.

Plus, what tool are you using to look at the destination data? Are you sure the connection that tool uses is UTF-8 as well?

4 Comments

Here is the SHOW CREATE TABLE code: CREATE TABLE Country ( id int(10) unsigned NOT NULL auto_increment, country varchar(255) NOT NULL, PRIMARY KEY (id) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 how do i get the collation ?
i use --default-character-set=utf8 to import data using mysql < file
to look at destination data i use mysql client, and yes, i'm sure it is a utf8 connection: | character_set_client | utf8 | | character_set_connection | utf8 |
Character sets and table/column collations are not the same. What collation are your tables/columns? What does DESCRIBE say? Check dev.mysql.com/doc/refman/5.0/en/charset.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.