Documentation Home
MySQL 8.4 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 39.8Mb
PDF (A4) - 39.9Mb
Man Pages (TGZ) - 257.9Kb
Man Pages (Zip) - 364.9Kb
Info (Gzip) - 4.0Mb
Info (Zip) - 4.0Mb


MySQL 8.4 Reference Manual  /  Character Sets, Collations, Unicode

Chapter 12 字符集、排序规则、Unicode

Table of Contents

12.1 字符集和排序规则概述
12.2 MySQL 中的字符集和排序规则
12.2.1 字符集曲目
12.2.2 元数据的 UTF-8
12.3 指定字符集和排序规则
12.3.1 排序规则命名约定
12.3.2 服务器字符集和排序规则
12.3.3 数据库字符集和排序规则
12.3.4 表字符集和排序规则
12.3.5 列字符集和排序规则
12.3.6 字符串文字的字符集和排序规则
12.3.7 国家字符集
12.3.8 字符集介绍符
12.3.9 字符集和排序规则赋值示例
12.3.10 与其他 DBMS 的兼容性
12.4 连接字符集和排序规则
12.5 配置应用程序字符集和排序规则
12.6 错误消息字符集
12.7 列字符集转换
12.8 排序规则问题
12.8.1 在 SQL 语句中使用 COLLATE
12.8.2 COLLATE 子句优先级
12.8.3 字符集和排序规则兼容性
12.8.4 表达式中的排序规则强制性
12.8.5 二进制排序规则与 _bin 排序规则的比较
12.8.6 排序规则影响的示例
12.8.7 在 INFORMATION_SCHEMA 搜索中使用排序规则
12.9 Unicode 支持
12.9.1 The utf8mb4 Character Set (4-Byte UTF-8 Unicode Encoding)
12.9.2 The utf8mb3 Character Set (3-Byte UTF-8 Unicode Encoding)
12.9.3 The utf8 Character Set (Deprecated alias for utf8mb3)
12.9.4 The ucs2 Character Set (UCS-2 Unicode Encoding)
12.9.5 The utf16 Character Set (UTF-16 Unicode Encoding)
12.9.6 The utf16le Character Set (UTF-16LE Unicode Encoding)
12.9.7 The utf32 Character Set (UTF-32 Unicode Encoding)
12.9.8 Converting Between 3-Byte and 4-Byte Unicode 字符集
12.10 支持的字符集和排序规则
12.10.1 Unicode 字符集
12.10.2 西欧字符集
12.10.3 中欧字符集
12.10.4 南欧和中东字符集
12.10.5 波罗的海字符集
12.10.6 西里尔字符集
12.10.7 亚洲字符集
12.10.8 二进制字符集
12.11 字符集的限制
12.12 设置错误消息语言
12.13 添加字符集
12.13.1 字符定义数组
12.13.2 复杂字符集的字符串排序支持
12.13.3 复杂字符集的多字节字符支持
12.14 向字符集添加排序规则
12.14.1 排序规则实现类型
12.14.2 选择排序规则 ID
12.14.3 向 8 位字符集添加简单排序规则
12.14.4 向 Unicode 字符集添加 UCA 排序规则
12.15 字符集配置
12.16 MySQL 服务器区域设置支持

MySQL includes character set support that enables you to store data using a variety of character sets and perform comparisons according to a variety of collations. The default MySQL server character set and collation are utf8mb4 and utf8mb4_0900_ai_ci, but you can specify character sets at the server, database, table, column, and string literal levels.

This chapter discusses the following topics:

  • What are character sets and collations?

  • The multiple-level default system for character set assignment.

  • Syntax for specifying character sets and collations.

  • Affected functions and operations.

  • Unicode support.

  • The character sets and collations that are available, with notes.

  • Selecting the language for error messages.

  • Selecting the locale for day and month names.

Character set issues affect not only data storage, but also communication between client programs and the MySQL server. If you want the client program to communicate with the server using a character set different from the default, you'll need to indicate which one. For example, to use the utf8mb4 Unicode character set, issue this statement after connecting to the server:

SET NAMES 'utf8mb4';

For more information about configuring character sets for application use and character set-related issues in client/server communication, see Section 12.5, “Configuring Application Character Set and Collation”, and Section 12.4, “Connection Character Sets and Collations”.