utf-8 时变化长度的编码,储存一个code point 需要1~4个字节.

然而,mysql的utf8只存储最多3个字节per code point.

所以,utf8字符集不能存储所有的unicode code points.

只能从0x000 to 0xFFFF(叫做Basic Multilingual Plane:BMP)  

The character set named utf8 uses a maximum of three bytes per character and contains only BMP characters. As of MySQL 5.5.3, the utf8mb4 character set uses a maximum of four bytes per character supports supplemental characters:

  • For a BMP character, utf8 and utf8mb4 have identical storage characteristics: same code values, same encoding, same length.

  • For a supplementary character, utf8 cannot store the character at all, while utf8mb4 requires four bytes to store it. Since utf8 cannot store the character at all, you do not have any supplementary characters in utf8 columns and you need not worry about converting characters or losing data when upgrading utf8 data from older versions of MySQL.

So if you want your column to support storing characters lying outside the BMP (and you usually want to), such as emoji, use "utf8mb4". See also What are the most common non-BMP Unicode characters in actual use?.

MySQL utf8 和 utf8mb4 的区别的更多相关文章

  1. Java Unicode编码 及 Mysql utf8 utf8mb3 utf8mb4 的区别与utf8mb4的过滤

    UTF-8简介 UTF-8(8-bit Unicode Transformation Format)是一种针对Unicode的可变长度字符编码,也是一种前缀码.它可以用来表示Unicode标准中的任何 ...

  2. MySQL中 utf8与utf8mb4的区别

    MySQL中 utf8与utf8mb4的区别 一.简介 ​ MySQL在5.5.3之后增加了这个utf8mb4的编码,mb4就是most bytes 4的意思,专门用来兼容四字节的unicode.好在 ...

  3. mysql字符集 utf8 和utf8mb4 的区别

    一.导读我们新建mysql数据库的时候,需要指定数据库的字符集,一般我们都是选择utf8这个字符集,但是还会又一个utf8mb4这个字符集,好像和utf8有联系,今天就来解析一下这两者的区别. 二.起 ...

  4. mysql utf8改utf8mb4

    由于需要用到utf8mb4,之前是utf8现在给改成utf8mb4 查看当前环境 SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' ...

  5. Emoji表情符号录入MySQL数据库报错的解决方案(MySQL utf8与utf8mb4区别)

    本文转自:http://blog.itpub.net/26230597/viewspace-1243233/前言:手机app应用评论的时候,恢复表情符号,提示失败. 1,查看tomcat后台日志,核心 ...

  6. MySQL 数据库字符集 utf8 和 utf8mb4 的区别

    参考于今日头条上Java芋道源码的-----记住:永远不要在 MySQL 中使用 UTF-8 字符集选择 MySQL 的 utf8 实际上不是真正的 UTF-8.utf8 只支持每个字符最多三个字节, ...

  7. utf8与utf8mb4的区别

    最近在写一个爬虫的多线程脚本,在异步插入数据库的时候总有部分数据插入失败,原因竟然是编码的问题.扪心自问,mysql最通用的中文字符编码就是utf-8了,通常情况下,utf-8作为中文编码是司空见惯的 ...

  8. utf8和utf8mb4的区别

    一.简介 MySQL在5.5.3之后增加了这个utf8mb4的编码,mb4就是most bytes 4的意思,专门用来兼容四字节的unicode.好在utf8mb4是utf8的超集,除了将编码改为ut ...

  9. MySQL UTF8 转为 utf8mb4

    https://mathiasbynens.be/notes/mysql-utf8mb4#utf8-to-utf8mb4 How to support full Unicode in MySQL da ...

随机推荐

  1. openvas漏洞扫描

    openvas配置步骤 1.-因为老师给的kali中自带的openvas,所以我们可以直接执行命令:openvas-check-setup来查看下他的安装状态: 如下图所示:在步骤7中出现错误,其中图 ...

  2. Codeforces 834D The Bakery - 动态规划 - 线段树

    Some time ago Slastyona the Sweetmaid decided to open her own bakery! She bought required ingredient ...

  3. cygwin下如何编译安装minicom?

    1. 安装依赖的软件和库 apt-cyg install autoconf automake make libncurses-devel (apt-cyg工具的安装方法在此) 2. 获取源码 wget ...

  4. aria2的下载配置

    aria2的命令行命令是: aria2c 一种方式: aria2c "http://host/file.zip" 如同wget 第二种方式: rpc server方式:

  5. MySQL 5.7的原生JSON数据类型使用

    新增测试用表: CREATE TABLE lnmp ( `id` ) unsigned NOT NULL AUTO_INCREMENT, `category` JSON, `tags` JSON, P ...

  6. BFS广度优先 vs DFS深度优先 for Binary Tree

    https://www.geeksforgeeks.org/bfs-vs-dfs-binary-tree/ What are BFS and DFS for Binary Tree? A Tree i ...

  7. hihoCoder week17 最近公共祖先·三 lca st表

    记录dfs序列,dfn[tot] 记录第tot次访问的节点 然后查两点在dfs序中出现的第一次 id[u] id[v] 然后  找 dep[k] = min( dep[i] ) {i 属于 [id[u ...

  8. Docker5之Deploy your app

    Make sure you have published the friendlyhello image you created by pushing it to a registry. We’ll ...

  9. 51nod 1689 逛街(优先队列)

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1689 题意: 题意: 枚举终点,这样就确定路上的花费,接下来只需要计算进 ...

  10. linux服务器安装brook服务端 使用brook客户端

    既然你已经找到了此文章,说明已经知道brook的用途了,不做介绍,下面讲安装方法: 连接服务器,随便cd一个安装目录,例如: mkdir brook && cd brook 2.进re ...