Chapter 12 字符集、排序规则、Unicode
Table of Contents
- 12.1 字符集和排序规则概述
- 12.2 MySQL 中的字符集和排序规则
- 12.3 指定字符集和排序规则
- 12.4 连接字符集和排序规则
- 12.5 配置应用程序字符集和排序规则
- 12.6 错误消息字符集
- 12.7 列字符集转换
- 12.8 排序规则问题
- 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.11 字符集的限制
- 12.12 设置错误消息语言
- 12.13 添加字符集
- 12.14 向字符集添加排序规则
- 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”.