默认情况下,mysqld 会以英语生成错误消息,但这些消息也可以显示为其他多种语言:捷克语、丹麦语、荷兰语、爱沙尼亚语、法语、德语、希腊语、匈牙利语、意大利语、日语、韩语、挪威语、挪威语-尼诺斯克、波兰语、葡萄牙语、罗马尼亚语、俄语、斯洛伐克语、西班牙语或瑞典语。这适用于服务器写入错误日志和发送给客户端的消息。By default, mysqld produces error messages in English, but they can be displayed instead in any of several other languages: Czech, Danish, Dutch, Estonian, French, German, Greek, Hungarian, Italian, Japanese, Korean, Norwegian, Norwegian-ny, Polish, Portuguese, Romanian, Russian, Slovak, Spanish, or Swedish. This applies to messages the server writes to the error log and sends to clients.
要选择服务器显示错误消息的语言,请按照本节说明操作。有关更改错误消息字符集(而非语言)的信息,请参见 第 12.6 节“错误消息字符集”。有关配置错误日志的一般信息,请参见 第 7.4.2 节“错误日志”。To select the language in which the server writes error messages, follow the instructions in this section. For information about changing the character set for error messages (rather than the language), see Section 12.6, “Error Message Character Set”. For general information about configuring error logging, see Section 7.4.2, “The Error Log”.
服务器使用以下规则搜索错误消息文件:The server searches for the error message file using these rules:
它会在由两个系统变量值构建的目录中查找文件,
lc_messages_dir和lc_messages,后者会被转换为语言名称。假设你使用以下命令启动服务器:It looks for the file in a directory constructed from two system variable values,lc_messages_dirandlc_messages, with the latter converted to a language name. Suppose that you start the server using this command:mysqld --lc_messages_dir=/usr/share/mysql --lc_messages=fr_FR
在这种情况下,mysqld 将区域设置
fr_FR映射为语言french,并在/usr/share/mysql/french目录中查找错误文件。In this case, mysqld maps the localefr_FRto the languagefrenchand looks for the error file in the/usr/share/mysql/frenchdirectory.默认情况下,语言文件位于 MySQL 基目录下的
share/mysql/目录中。By default, the language files are located in theLANGUAGEshare/mysql/directory under the MySQL base directory.LANGUAGE如果在刚才描述的目录中找不到消息文件,服务器将忽略
lc_messages的值,只使用lc_messages_dir的值作为查找位置。If the message file cannot be found in the directory constructed as just described, the server ignores thelc_messagesvalue and uses only thelc_messages_dirvalue as the location in which to look.如果服务器找不到配置的消息文件,它会在错误日志中写入一条消息以指示问题,并默认使用内置的英文消息。If the server cannot find the configured message file, it writes a message to the error log to indicate the problem and defaults to built-in English messages.
lc_messages_dir 系统变量只能在服务器启动时设置,并且在运行时只能以全局只读值存在。lc_messages 可以在服务器启动时设置,并且具有全局和值会话值,可在运行时修改。因此,错误消息语言可以在服务器运行时更改,并且每个客户端可以通过将其会话 lc_messages 值设置为所需的区域名称来拥有自己的错误消息语言。例如,如果服务器正在使用 fr_FR 区域的错误消息,客户端可以执行此语句以接收英文的错误消息:The lc_messages_dir system
variable can be set only at server startup and has only a global
read-only value at runtime.
lc_messages can be set at server
startup and has global and session values that can be modified at
runtime. Thus, the error message language can be changed while the
server is running, and each client can have its own error message
language by setting its session
lc_messages value to the desired
locale name. For example, if the server is using the
fr_FR locale for error messages, a client can
execute this statement to receive error messages in English:
SET lc_messages = 'en_US';