When to use utf-8 and when to use latin1 in MySQL?

后端 未结 8 1727
暖寄归人
暖寄归人 2021-02-13 21:56

I know that MySQL has default of latin1 encoding and apparently it takes 1 byte to store a character in latin1 and 3 bytes to store a character in

8条回答
  •  暖寄归人
    2021-02-13 22:25

    At a bare minimum I would suggest using UTF-8. Your data will be compatible with every other database out there nowadays since 90%+ of them are UTF-8.

    If you go with LATIN1/ISO-8859-1 you risk the data being not properly stored because it doesn't support international characters... so you might run into something like the left side of this image:

    enter image description here

    If you go with UTF-8, you don't need to deal with these headaches.

    Regarding your error, it sounds like you need to optimize your database. Consider this: http://bugs.mysql.com/bug.php?id=4541#c284415

    It would help if you gave specifics on your table schema and column for that issue.

提交回复
热议问题