文档首页
MySQL 8.4 参考手册
8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 100%

12.3 指定字符集和排序规则12.3 Specifying Character Sets and Collations

字符集和排序规则在四个层级上有默认设置:服务器、数据库、表和列。以下各节中的描述可能看起来复杂,但实践中发现,多层级的默认设置会产生自然且明显的结果。There are default settings for character sets and collations at four levels: server, database, table, and column. The description in the following sections may appear complex, but it has been found in practice that multiple-level defaulting leads to natural and obvious results.

CHARACTER SET 用于指定字符集的子句中。CHARSET 可以作为 CHARACTER SET 的同义词使用。CHARACTER SET is used in clauses that specify a character set. CHARSET can be used as a synonym for CHARACTER SET.

字符集问题不仅影响数据存储,还会影响客户端程序与 MySQL 服务器之间的通信。如果希望客户端程序使用不同于默认的字符集与服务器进行通信,需要指明所使用的字符集。例如,要使用 latin1 Unicode 字符集,在连接服务器后执行以下语句: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 need to indicate which one. For example, to use the latin1 Unicode character set, issue this statement after connecting to the server:

SET NAMES 'latin1';

有关客户端/服务器通信中字符集相关问题的更多信息,请参见 第 12.4 节,“连接字符集和排序规则”。For more information about character set-related issues in client/server communication, see Section 12.4, “Connection Character Sets and Collations”.