Convert data from latin1_swedish to utf-8

别等时光非礼了梦想. 提交于 2019-12-11 02:26:31

问题


I need to convert data from old database to new one. Old database was in latin1_swedish_ci collation and have content in cyrilic language like this

<p>ÐрхиепиÑкоп охридÑки и ми...

This content with utf-8 enconding on page looks like this

<p>Архиепископ охридски и митрополит скопски ...

Which is fine. Now I need to convert all of this data into native UTF-8 content. No expirience with these, any sugg. Thanks


回答1:


You can try this

ALTER TABLE <tablename> CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci

And note that , this will affect existing column collations also. If you want to change default collasion to utf8 , must change database collation. After that all new table will be utf8




回答2:


From the manual,

ALTER TABLE t MODIFY col1 CHAR(50) CHARACTER SET utf8;

However, if you have characters that cannot be converted then you will lose that data. First make a backup and try it there.



来源:https://stackoverflow.com/questions/10108550/convert-data-from-latin1-swedish-to-utf-8

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!