Mysql throw incorrect string value exception analysis _mysql
Source: Internet
Author: User
Previously thought that from the top to the next unified use of UTF-8 on the rest of the peace of the day, but today in the crawl Sina Weibo data is still encountered the exception of characters.
The data captured by Sina Weibo throws an exception when it is in storage:
Incorrect string value: ' \xf0\x90\x8d\x83\xf0\x90 ... '
found that the character that caused the exception is not traditional but some kind of Buddhist text ... The forehead drops the god ... But according to reason UTF-8 should be able to support just ah, he is not omnipotent?
The original problem in MySQL, MySQL if you set the encoding set to UTF8 then it can only support up to 3 bytes of UTF-8 encoding, and 4 bytes of UTF-8 characters still exist, so if you build the table when the UTF8 character set out of the exception is taken for granted.
The workaround is simple, and modifying the field or table's character set is UTF8MB4.
Compared to the egg pain is that the character set utf8mb4 after the MySQL 5.5.3 support.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service