8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

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

打开官方英文原文 ↗

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

MySQL 8.4 参考手册 / 6 个 MySQL 程序 / 6.10 MySQL 中的 Unix 信号处理
中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 100%

6.10 MySQL 中的 Unix 信号处理6.10 Unix Signal Handling in MySQL

在 Unix 及类 Unix 系统中,进程可以接收由 root 系统账户或拥有该进程的系统账户发送给它的信号。信号可以使用 kill 命令发送。一些命令解释器将特定的按键序列与信号关联,例如 Control+C 用于发送 SIGINT 信号。本节描述了 MySQL 服务器和客户端程序如何响应信号。On Unix and Unix-like systems, a process can be the recipient of signals sent to it by the root system account or the system account that owns the process. Signals can be sent using the kill command. Some command interpreters associate certain key sequences with signals, such as Control+C to send a SIGINT signal. This section describes how the MySQL server and client programs respond to signals.

服务器对信号的响应Server Response to Signals

mysqld 对信号的响应如下:mysqld responds to signals as follows:

  • SIGTERM 会导致服务器关闭。这类似于执行一个 SHUTDOWN 语句,而无需连接到服务器(对于关闭操作,需要具有 SHUTDOWN 权限的账户)。SIGTERM causes the server to shut down. This is like executing a SHUTDOWN statement without having to connect to the server (which for shutdown requires an account that has the SHUTDOWN privilege).

  • SIGHUP 会导致服务器重新加载权限表并刷新表、日志、线程缓存和主机缓存。这些操作类似于各种形式的 FLUSH 语句。发送该信号可以在不必连接到服务器的情况下执行刷新操作,而连接服务器通常需要具有足够权限的 MySQL 账户。SIGHUP causes the server to reload the grant tables and to flush tables, logs, the thread cache, and the host cache. These actions are like various forms of the FLUSH statement. Sending the signal enables the flush operations to be performed without having to connect to the server, which requires a MySQL account that has privileges sufficient for those operations.

  • SIGUSR1 会导致服务器刷新错误日志、通用查询日志和慢查询日志。SIGUSR1 的一个用途是实现日志轮换而无需连接到服务器,这需要一个具有足够权限进行这些操作的 MySQL 账户。有关日志轮换的信息,请参见 第 7.4.6 节,“服务器日志维护”。SIGUSR1 causes the server to flush the error log, general query log, and slow query log. One use for SIGUSR1 is to implement log rotation without having to connect to the server, which requires a MySQL account that has privileges sufficient for those operations. For information about log rotation, see Section 7.4.6, “Server Log Maintenance”.

    服务器对SIGUSR1的响应是对SIGHUP的响应的一个子集,使得SIGUSR1可以被用作一个更“轻量级”的信号,用于刷新某些日志而不产生其他SIGHUP影响,如刷新线程和主机缓存以及向错误日志写入状态报告。The server response to SIGUSR1 is a subset of the response to SIGHUP, enabling SIGUSR1 to be used as a more “lightweight” signal that flushes certain logs without the other SIGHUP effects such as flushing the thread and host caches and writing a status report to the error log.

  • SIGINT 通常会被服务器忽略。使用 --gdb 选项启动服务器会为调试目的安装 SIGINT 中断处理程序。参见 第 7.9.1.4 节,“在 gdb 下调试 mysqld”。SIGINT normally is ignored by the server. Starting the server with the --gdb option installs an interrupt handler for SIGINT for debugging purposes. See Section 7.9.1.4, “Debugging mysqld under gdb”.

客户端对信号的响应Client Response to Signals

MySQL 客户端程序对信号的响应如下:MySQL client programs respond to signals as follows:

  • mysql 客户端将 SIGINT(通常是输入 Control+C 的结果)解释为中断当前语句(如果有的话)的指令,或者取消任何部分输入行。可以使用 --sigint-ignore 选项来忽略 SIGINT 信号,从而禁用此行为。The mysql client interprets SIGINT (typically the result of typing Control+C) as instruction to interrupt the current statement if there is one, or to cancel any partial input line otherwise. This behavior can be disabled using the --sigint-ignore option to ignore SIGINT signals.

  • 使用 MySQL 客户端库的客户端程序默认会阻塞 SIGPIPE 信号。可能存在以下变体:Client programs that use the MySQL client library block SIGPIPE signals by default. These variations are possible: