开发者

How to export/import utf8-general-ci database?

In my database on localhost, the data is saved in utf8-general-ci . This is an exmple of my data record in utf8 which I see in phpmyadmin: "M�y t�nh b?ng Superpad 10.2 inch" . However, after I export it to sql file, all the unicode character become the question mark as follow: "Máy tính b?ng Superpad 10.2 inch". How could I solve this problem? One more problem is that if I import it back to another database with the same mysql version on localhost, I saw that the data is saved in开发者_JS百科 the new database the same as "M�y t�nh b?ng Superpad 10.2 inch", but when I used the new database on the web application, the data is displayed as follow: "Máy tính b?ng Superpad 10.2 inch" . I don't know what happen and could you please give me some fundamental article about export/import data in mysql with utf charset?

Thanks and best regards.


You can use mysqldump to dump the data with utf8 characters. If you are using mysql<5x then run:

mysqldump --default-character-set=utf8 db_name > dump.sql

Because newer release of mysqldump uses UTF8 as its default charset if nothing is specified, while older versions (older than 4.1 typically) use Latin1 as default characterset.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜