-
mysql默认排序规则utf8mb4_MySQL utf8mb4排序规则
2021-01-19 17:36:24文章直通车:utf8mb4 和 utf8utf8mb4排序规则一、先了解下 utf8mb4 和 utf8参考MySQL文档:utf8mb4: A UTF-8 encoding of the Unicode character set using one to four bytes per character.utf8mb3: A UTF-8 ...文章直通车:
utf8mb4 和 utf8
utf8mb4排序规则
一、先了解下 utf8mb4 和 utf8
参考MySQL文档:
utf8mb4: A UTF-8 encoding of the Unicode character set using one to four bytes per character.
utf8mb3: A UTF-8 encoding of the Unicode character set using one to three bytes per character.
utf8: An alias for utf8mb3.
Note
The utf8mb3 character set is deprecated and will be removed in a future MySQL release. Please use utf8mb4 instead. Although utf8 is currently an alias for utf8mb3, at some point utf8 will become a reference to utf8mb4. To avoid ambiguity about the meaning of utf8, consider specifying utf8mb4 explicitly for character set references instead of utf8.
UTF-8是使用1~4个字节,一种变长的编码格式。(字符编码 )
mb4即 most bytes 4,使用4个字节来表示完整的UTF-8。而MySQL中的utf8是utfmb3,只有三个字节,节省空间但不能表达全部的UTF-8(比如emoji表情),只能支持“基本多文种平面”(Basic Multilingual Plane,BMP)。
所以推荐使用utf8mb4。
二、utf8mb4排序规则:utf8mb4_unicode_ci、utf8mb4_general_ci、utf8mb4_bin
utf8mb4_unicode_ci 和 utf8mb4_general_ci 的对比:
To further illustrate, the following equalities hold in both utf8_general_ci and utf8_unicode_ci (for the effect of this in comparisons or searches, see Section 10.8.6, “Examples of the Effect of Collation”):
Ä = A
Ö = O
Ü = U
A difference between the collations is that this is true for utf8_general_ci:
ß = s
Whereas this is true for utf8_unicode_ci, which supports the German DIN-1 ordering (also known as dictionary order):
ß = ss
MySQL implements utf8 language-specific collations if the ordering with utf8_unicode_ci does not work well for a language. For example, utf8_unicode_ci works fine for German dictionary order and French, so there is no need to create special utf8 collations.
utf8_general_ci also is satisfactory for both German and French, except that ß is equal to s, and not to ss. If this is acceptable for your application, you should use utf8_general_ci because it is faster. If this is not acceptable (for example, if you require German dictionary order), use utf8_unicode_ci because it is more accurate.
utf8mb4_general_ci, utf8mb4_unicode_ci:ci即case insensitive,不区分大小写。
准确性:
utf8mb4_unicode_ci 是基于标准的Unicode来排序和比较,能够在各种语言之间精确排序
utf8mb4_general_ci 没有实现Unicode排序规则,在遇到某些特殊语言或者字符集,排序结果可能不一致。但是,在绝大多数情况下,这些特殊字符的顺序并不需要那么精确
性能:
utf8mb4_general_ci 在比较和排序的时候更快
utf8mb4_unicode_ci 在特殊情况下,Unicode排序规则为了能够处理特殊字符的情况,实现了略微复杂的排序算法。但是在绝大多数情况下发,不会发生此类复杂比较。相比选择哪一种collation,使用者更应该关心字符集与排序规则在db里需要统一。
utf8mb4_bin:将字符串每个字符用二进制数据编译存储,区分大小写,而且可以存二进制的内容。
参考:
https://dev.mysql.com/doc/refman/8.0/en/charset-unicode-sets.html
https://dev.mysql.com/doc/refman/8.0/en/charset-collation-effect.html
-
MySQL utf8mb4排序规则
2019-07-18 19:34:41utf8mb4排序规则 一、先了解下 utf8mb4 和 utf8 参考MySQL文档: utf8mb4: A UTF-8 encoding of the Unicode character set using one to four bytes per character. utf8mb3: A UTF-8 encoding of the Un...文章直通车:
一、先了解下 utf8mb4 和 utf8
- utf8mb4: A UTF-8 encoding of the Unicode character set using one to four bytes per character.
- utf8mb3: A UTF-8 encoding of the Unicode character set using one to three bytes per character.
- utf8: An alias for utf8mb3.
Note
The utf8mb3 character set is deprecated and will be removed in a future MySQL release. Please use utf8mb4 instead. Although utf8 is currently an alias for utf8mb3, at some point utf8 will become a reference to utf8mb4. To avoid ambiguity about the meaning of utf8, consider specifying utf8mb4 explicitly for character set references instead of utf8.UTF-8是使用1~4个字节,一种变长的编码格式。(字符编码 )
mb4即 most bytes 4,使用4个字节来表示完整的UTF-8。而MySQL中的utf8是utfmb3,只有三个字节,节省空间但不能表达全部的UTF-8(比如emoji表情),只能支持“基本多文种平面”(Basic Multilingual Plane,BMP)。
所以推荐使用utf8mb4。
二、utf8mb4排序规则:utf8mb4_unicode_ci、utf8mb4_general_ci、utf8mb4_bin
utf8mb4_unicode_ci 和 utf8mb4_general_ci 的对比:
To further illustrate, the following equalities hold in both utf8_general_ci and utf8_unicode_ci (for the effect of this in comparisons or searches, see Section 10.8.6, “Examples of the Effect of Collation”):
Ä = A
Ö = O
Ü = UA difference between the collations is that this is true for utf8_general_ci:
ß = s
Whereas this is true for utf8_unicode_ci, which supports the German DIN-1 ordering (also known as dictionary order):
ß = ss
MySQL implements utf8 language-specific collations if the ordering with utf8_unicode_ci does not work well for a language. For example, utf8_unicode_ci works fine for German dictionary order and French, so there is no need to create special utf8 collations.
utf8_general_ci also is satisfactory for both German and French, except that ß is equal to s, and not to ss. If this is acceptable for your application, you should use utf8_general_ci because it is faster. If this is not acceptable (for example, if you require German dictionary order), use utf8_unicode_ci because it is more accurate.
utf8mb4_general_ci, utf8mb4_unicode_ci:ci即case insensitive,不区分大小写。
准确性:
- utf8mb4_unicode_ci 是基于标准的Unicode来排序和比较,能够在各种语言之间精确排序
- utf8mb4_general_ci 没有实现Unicode排序规则,在遇到某些特殊语言或者字符集,排序结果可能不一致。但是,在绝大多数情况下,这些特殊字符的顺序并不需要那么精确
性能:
- utf8mb4_general_ci 在比较和排序的时候更快
- utf8mb4_unicode_ci 在特殊情况下,Unicode排序规则为了能够处理特殊字符的情况,实现了略微复杂的排序算法。但是在绝大多数情况下发,不会发生此类复杂比较。相比选择哪一种collation,使用者更应该关心字符集与排序规则在db里需要统一。
utf8mb4_bin:将字符串每个字符用二进制数据编译存储,区分大小写,而且可以存二进制的内容。
参考:
-
mysql默认排序规则utf8mb4_Mysql字符集和排序规则 - UTF8mb4 520
2021-01-28 08:52:34问题:由于缺少排序规则,mysqldump将无法导入1273 - 未知排序规则:'utf8mb4_unicode_520_ci'Mysql服务器是(来自phpMyAdmin):Server version: 5.5.40 - MySQL CommunityServer charset: UTF-8 Unicode (utf8)...问题:由于缺少排序规则,mysqldump将无法导入
1273 - 未知排序规则:'utf8mb4_unicode_520_ci'
Mysql服务器是(来自phpMyAdmin):
Server version: 5.5.40 - MySQL Community
Server charset: UTF-8 Unicode (utf8)
Database client version: libmysql - 5.0.95
这是一个centos 5.11服务器 .
mysql> show variables where Variable_name like 'character\_set\_%' or Variable_n ame like 'collation%';
+--------------------------+-----------------+
| Variable_name | Value |
+--------------------------+-----------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | utf8_general_ci |
+--------------------------+-----------------+
10 rows in set (0.00 sec)
我有本地服务器(xampp)
> Server version: 10.1.9-MariaDB - mariadb.org binary distribution
> Server charset: UTF-8 Unicode (utf8) Database client version:
> libmysql - mysqlnd 5.0.11-dev - 20120503 - $Id:
> 3c688b6bbc30d36af3ac34fdd4b7b5b787fe5555 $
这进口罚款 . 查看导入的最终表,我看到所有表的排序规则都是utf8mb4_unicode_ci . 当我上传到公共服务器时,同样的情况发生(即我的本地导入正确)
Server version: 5.6.29 - MySQL Community Server (GPL)
Database client version: libmysql - 5.1.73
Why does my local database handle the 520 collation whereas the centos box does not?
任何指向正确方向的人都会受到赞赏 . 所有上传都是通过上面的规范通过phpMyAdmin执行的 . 我知道我可以“更新”SQL转储并删除'520'引用,只需用utf8mb4_unicode_ci替换,但如果每次都不经常这样做就必须这样做 .
-
mysql创建数据库指定编码utf8和排序规则utf8mb4_general_ci
2020-07-09 10:22:19create database database default character set utf8mb4 collate utf8mb4_general_ci;create database databasename default character set utf8mb4 collate utf8mb4_general_ci;
-
MySQL 8 创建数据库和建表使用字符集和排序规则utf8 utf8mb4 和utf8mb4_general_ci utf8mb4_unicode_ci
2020-07-18 19:59:00新的项目启动后,创建数据库使用的一般需要创建默认字符集(CHARACTER)和排序规则(COLLATE)。 以下是我创建表使用的字符集和排序规则。 CREATE DATABASE `springcloud` DEFAULT CHARACTER SET utf8mb4 COLLATE ... -
mysql创建库和表确保utf8_MySQL 8 创建数据库和建表使用字符集和排序规则utf8 utf8mb4 和utf8mb4_general_c...
2021-01-20 01:03:47新的项目启动后,创建数据库使用的一般需要创建默认字符集(CHARACTER)和排序规则(COLLATE)。以下是我创建表使用的字符集和排序规则。CREATE DATABASE `spring...字符集排序规则utf8…utf8_general_ciutf8_unicode_... -
MySQL常用排序规则utf8mb4_general_ci、utf8mb4_unicode_ci、utf8mb4_bin
2021-02-23 13:34:45文章目录一、MySQL常用排序规则...mysql的 utf8 编码最大字符长度为 3 字节,如果遇到 4 字节的宽字符就会插入异常了。三个字节的 UTF-8 最大能编码的 Unicode 字符是 0xffff,也就是 Unicode 中的基本多文种平面(BMP -
mysql 建库 utf8 排序_关于Mysql数据库建库字符集utf8mb4下,排序规则utf8mb4_bin和utf8mb4_general_ci选择...
2021-01-19 15:21:50骚操作:在A库中把表建好了,copy到B库中,导致库表的排序规则不一致大小写匹配的时候出现问题。 逻辑描述: 在数据从app入库的时候存储的是大写的字符code:123XXX,然后数据库查询的时候传入的是小写的code:123... -
mysql排序规则utf8_如何将整个MySQL数据库字符集和排序规则转换为UTF-8?
2021-01-19 06:22:49在命令行shell上如果您是命令行shell,您可以...只需填写“dbname”:dDB="dbname"(echo'ALTERDATABASE`'"$DB"'`CHARACTERSETutf8COLLATEutf8_general_ci;'mysql"$DB"-e"SHOWTABLES"--batch--skip-column-names\|xa... -
UTF-8 字符集排序规则
2015-04-28 10:53:57utf8_general_ci 不区分大小写,这个你在注册用户名和邮箱的时候就要...utf8_bin: compare strings by the binary value of each character in the string 将字符串每个字符串用二进制数据编译存储。 区分大小写,而且 -
utf-8mb4和排序规则
2019-04-07 17:08:00MySQL在5.5.3之后增加了这个utf8mb4的编码,mb4就是most bytes 4的意思,专门用来兼容四字节的unicode。 最新的 UTF-8 规范只使用一到四个字节,最大能编码21位,正好能够表示所有的 17个 Unicode 平面。 mysql... -
Mysql中的排序规则utf8_unicode_ci、utf8_general_ci的区别
2018-12-26 14:02:37Mysql中的排序规则utf8_unicode_ci、utf8_general_ci的区别 utf8_unicode_ci和utf8_general_ci对中、英文来说没有实质的差别。 utf8_general_ci 校对速度快,但准确度稍差。 utf8_unicode_ci 准确度高,但校对速度... -
mysql默认排序规则utf8mb4_mysql – 虽然排序规则是utf8mb4_unicode_ci,但SQL并没有区分u和ü...
2021-01-28 08:52:38字符集只是一个“无序”的字符列表及其表示.utf8mb4是一个字符集,涵盖了很多字符.排序规则定义字符的顺序(例如,确定顺序的最终结果)并定义其他规则(例如应将哪些字符或字符组合视为相同).排序是从字符集派生的,对于... -
Mysql中的排序规则utf8_unicode_ci、utf8_general_ci的区别总结
2020-09-10 16:13:12Mysql中utf8_general_ci与utf8_unicode_ci有什么区别呢?在编程语言中,通常用unicode对中文字符做处理,防止出现乱码,那么在MySQL里,为什么大家都使用utf8_general_ci而不是utf8_unicode_ci呢? -
mysql utf8mb4 bin_MySQL中utf8字符集、排序规则及utf8mb4_bin列大小写不敏感方法
2021-01-19 10:43:35utf8mb4 和 utf8 比较utf8mb4: A UTF-8 encoding of the Unicode character set using one to four bytes per character.utf8mb3: A UTF-8 encoding of the Unicode character set using one to three bytes per ... -
字符集utf8中文排序问题
2017-05-24 17:30:48数据库字符集: utf8排序规则:utf8_generay_ci表结构:mysql> desc chr;+------------+---------------+------+-----+---------+-------+| Field | Type | Null | Key | Default | Extra |+-----------... -
mysql中utf8排列顺序_Mysql中的排序规则utf8_unicode_ci、utf8_general_ci的区别总结
2021-03-15 12:33:44Mysql中的排序规则utf8_unicode_ci、utf8_general_ci的区别总结用了这么长时间,发现自己竟然不知道utf_bin和utf_general_ci这两者到底有什么区别。。ci是 case insensitive, 即 "大小写不敏感", a 和 A 会在字符... -
MySQL中utf8字符集、排序规则及utf8mb4_bin列大小写不敏感方法
2018-07-09 16:26:00转载:https://my.oschina.net/u/1245414/blog/1831347一、utf8mb4 和 utf8 比较utf8mb4: A UTF-8 encoding of the Unicode character set using one to four bytes per character.utf8mb3: A UTF-8 encoding of the... -
Mysql的utf8与utf8mb4字符集之间和集中排序规则之间的区别
2019-11-06 10:35:09utf8 与 utf8mb4 标准的 UTF-8 字符集编码是可以用 1~4 个字节去编码21位字符,是一种变长的编码格式,这几乎包含了是世界上所有能看见的语言了。然而在MySQL里实现的utf8最长使用3个字节,节省空间但不能表达全部... -
MYSQL建库utf-8mb4的相关排序规则
2021-01-11 20:22:48MySQL在5.5.3之后增加了这个utf8mb4的编码,mb4就是most bytes 4的意思,专门用来兼容四字节的unicode。 最新的 UTF-8 规范只使用一到四个字节,最大能编码21位,正好能够表示所有的 17个 Unicode 平面。 mysql支持... -
MySQL排序规则utf8_unicode_ci与utf8_general_ci的区别
2018-06-07 19:14:34utf8_general_ci和utf8_unicode_ci对于中英文没有实质上的区别 utf8_general_ci相对来说速度更快,但准确性相对较差 utf8_unicode_ci相对来说准确性更好,但速度慢点 详细区别: 1、对于一种... -
mysql unicode排序语句_Mysql中的排序规则utf8_unicode_ci、utf8_general_ci总结
2021-03-03 19:26:17Mysql中utf8_general_ci与utf8_unicode_ci有什么区别呢?在编程语言中,通常用unicode对中文字符做处理,防止出现乱码,那么在MySQL里,为什么大家都使用utf8_general_ci而不是utf8_unicode_ci呢?ci是 case ... -
Mysql中的排序规则utf8_bin,utf8_unicode_ci、utf8_general_ci的区别总结
2018-06-18 21:50:59Mysql中utf8_general_ci与utf8_unicode_ci有什么区别呢?在编程语言中,通常用unicode对中文字符做处理,防止出现乱码,那么在MySQL里,为什么大家都使用utf8_general_ci而不是utf8_unicode_ci呢?用了这么长时间,... -
Mysql中utf8mb4编码及排序规则之utf8mb4_bin, utf8mb4_general_ci, utf8mb4_unicode_cli三者区别
2020-09-14 10:57:48前言:utf8mb4说明 UTF-8是使用1~4个字节,一种变长的编码格式,字符编码。mb4即 most bytes 4,使用4个字节来表示完整的UTF-8。 mysql的 utf8 编码最大字符长度为 3 字节,如果遇到 4 字节的宽字符就会插入异常了...