Converting mysql tables from latin1 to utf8

后端 未结 2 1336
北恋
北恋 2020-12-13 15:45

I\'m trying to convert some mysql tables from latin1 to utf8. I\'m using the following command, which seems to mostly work.

ALTER TABLE tablename CONVERT TO          


        
相关标签:
2条回答
  • 2020-12-13 15:58

    UTF8_GENERAL_CI is accent insensitive.

    Use UTF8_BIN or a language-specific collation.

    0 讨论(0)
  • 2020-12-13 16:24

    The reason why the strings 'Drü' and 'Dru' evaluate as the same is that in the utf8_general_ci collation, they count as "the same". The purpose of a collation for a character set is to provide a set of rules as to when strings are the same, when one sorts before the other, and so on.

    If you want a different set of comparison rules, you need to choose a different collation. You can see the available collations for the utf8 character set by issuing SHOW COLLATION LIKE 'utf8%'. There are a bunch of collations intended for text that is mostly in a specific language; there is also the utf8_bin collation which compares all strings as binary strings (i.e. compares them as sequences of 0s and 1s).

    0 讨论(0)
提交回复
热议问题