MySQL Server has several logs that can help you find out what activity is taking place.MySQL Server有几个日志可以帮助您了解正在发生的活动。
Error log | |
Binary log | |
Relay log | |
long_query_time seconds to executelong_query_time 秒的查询 |
|
DDL log (metadata log) |
By default, no logs are enabled, except the error log on Windows. 默认情况下,除Windows上的错误日志外,不启用任何日志。(The DDL log is always created when required, and has no user-configurable options; see The DDL Log.) (DDL日志总是在需要时创建,并且没有用户可配置的选项;请参阅DDL日志。)The following log-specific sections provide information about the server options that enable logging.以下特定于日志的部分提供了有关启用日志记录的服务器选项的信息。
By default, the server writes files for all enabled logs in the data directory. 默认情况下,服务器会为数据目录中所有启用的日志写入文件。You can force the server to close and reopen the log files (or in some cases switch to a new log file) by flushing the logs. 您可以通过刷新日志来强一致性务器关闭并重新打开日志文件(或者在某些情况下切换到新的日志文件)。Log flushing occurs when you issue a 当您发出FLUSH LOGS
statement; execute mysqladmin with a flush-logs
or refresh
argument; or execute mysqldump with a --flush-logs
or --master-data
option. FLUSH LOGS
语句时,会发生日志刷新;使用刷新日志或刷新参数执行mysqladmin;或者使用--flush-logs
或--master-data
选项执行mysqldump。See Section 13.7.8.3, “FLUSH Statement”, Section 4.5.2, “mysqladmin — A MySQL Server Administration Program”, and Section 4.5.4, “mysqldump — A Database Backup Program”. 请参阅第13.7.8.3节,“FLUSH语句”、第4.5.2节,“mysqladmin MySQL Server管理程序”和第4.5.4节,“mysqldump数据库备份程序”。In addition, the binary log is flushed when its size reaches the value of the 此外,当二进制日志的大小达到max_binlog_size
system variable.max_binlog_size
系统变量的值时,会刷新该日志。
You can control the general query and slow query logs during runtime. You can enable or disable logging, or change the log file name. 您可以在运行时控制常规查询和慢速查询日志。您可以启用或禁用日志记录,也可以更改日志文件名。You can tell the server to write general query and slow query entries to log tables, log files, or both. 您可以告诉服务器将常规查询和慢速查询条目写入日志表、日志文件,或同时写入这两个条目。For details, see Section 5.4.1, “Selecting General Query Log and Slow Query Log Output Destinations”, Section 5.4.3, “The General Query Log”, and Section 5.4.5, “The Slow Query Log”.具体请参见第5.4.1节,“选择常规查询日志和慢速查询日志输出目的地”、第5.4.3节,“常规查询日志”和第5.4.5节,“慢速查询日志”。
The relay log is used only on replicas, to hold data changes from the replication source server that must also be made on the replica. For discussion of relay log contents and configuration, see Section 17.2.4.1, “The Relay Log”.中继日志仅用于副本,用于保存来自复制源服务器的数据更改,这些更改也必须在副本上进行。有关继电器日志内容和配置的讨论,请参阅第17.2.4.1节,“Relay日志”。
For information about log maintenance operations such as expiration of old log files, see Section 5.4.6, “Server Log Maintenance”.有关日志维护操作(如旧日志文件过期)的信息,请参阅第5.4.6节,“服务器日志维护”。
For information about keeping logs secure, see Section 6.1.2.3, “Passwords and Logging”.有关保持日志安全的信息,请参阅第6.1.2.3节,“密码和日志记录”。