[php]在存储utf-8编码格式的内容值utf-8格式字段是报错:Incorrect string value

这是由于存储文本中存在4字节的文字,mysql如果设置编码集为utf8那么它最多只能支持到3个字节的utf-8编码,想要支持4字节的utf-8编码,需要mysql字段类型更改为utf8mb4(mysql5.5.3版本之后才支持),在修改类型为utf8mb4是,单纯声明字段类型为utf8mb4会报错:error 1366 “Incorrect string value”;

 

MySQL has two different UTF-8 datatypes, UTF8 and UTF8mb4. If you want to store all possible UTF-8 characters, you have to use UTF8mb4 and you must convert your tables and columns, not only changing the definition. If not, you get an error 1366 “Incorrect string value”.

MySQL有两种不同的utf-8数据类型,UTF8和UTF8mb4。如果要存储所有可能的utf-8字符,必须使用UTF8mb4,并且必须转换表和列,而不仅仅是更改定义。如果没有,您将得到一个错误的1366“不正确的字符串值”。

posted @ 2018-01-23 14:57  hhao321  阅读(147)  评论(0编辑  收藏  举报