This documentation is for an older version. If you're using the most current version, select the documentation for that version with the version switch in the upper right corner of the online documentation, or by downloading a newer PDF or EPUB file.

5.4 MySQL Server Logs

5.4.1 The Error Log
5.4.2 The General Query Log
5.4.3 The Binary Log
5.4.4 The Slow Query Log
5.4.5 Server Log Maintenance

MySQL Server has several logs that can help you find out what activity is taking place.

Log TypeInformation Written to Log
Error logProblems encountered starting, running, or stopping mysqld
General query logEstablished client connections and statements received from clients
Binary logStatements that change data (also used for replication)
Relay logData changes received from a replication master server
Slow query logQueries that took more than long_query_time seconds to execute

By default, no logs are enabled (except the error log on Windows). 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. See Section, “FLUSH Syntax”, Section 4.5.2, “mysqladmin — Client for Administering a MySQL Server”, and Section 4.5.4, “mysqldump — A Database Backup Program”. In addition, the binary log is flushed when its size reaches the value of the max_binlog_size system variable.

The relay log is used only on slave replication servers, to hold data changes from the master server that must also be made on the slave. For discussion of relay log contents and configuration, see Section, “The Slave Relay Log”.

For information about log maintenance operations such as expiration of old log files, see Section 5.4.5, “Server Log Maintenance”.

For information about keeping logs secure, see Section, “Passwords and Logging”.