home support FAQ resources services partners contact us contact us
 MySQL Tutorial Previous  Next  
 

If you specify either of the InnoDB options, you should specify both, and you must give both the same value.

You can specify logging options on the command line for mysqld or mysqld_safe. However, because you usually specify log options the same way each time you start the server, it's most common to list them in an appropriate group of an option file. Typically, options are listed in the [mysqld] group, but they need not always be. The "Specifying Startup Options" section earlier in this chapter details the option groups applicable to the server and to the server startup programs.

Flushing the Logs

Flushing the logs causes the server to close and reopen the log files. This can be done by executing mysqladmin flush-logs or (as of MySQL 3.22.9) with a FLUSH LOGS statement. Sending a SIGHUP signal to the server also flushes the logs. (Another way to flush the logs is to use mysqladmin refresh, but that does other things as well, so it's overkill if you just want to flush the logs.)

Log flushing applies to the general log, update log, binary update log and index file, and slow-query log; but not to the error log or table handler-specific logs. For the binary log, flushing the logs causes the server to close the current log file and open a new one with the next number in the sequence. This also happens with the update log if you're generating a numbered series of update log files.

Log flushing can be useful for log expiration or rotation purposes, as discussed in the "Log File Expiration" section later in this chapter.

The General Query Log

This log contains a record of when clients connect to the server, each query that is sent to it by clients, and various other events that are not represented as queries (such as server startup and shutdown). If you enable the general log by specifying the --log option without a filename, the default name is HOSTNAME.log in the data directory.

Queries are written to this log in the order that the server receives them. This may well be different than the order in which they finish executing, particularly for a mix of short and long queries.

The Slow-Query Log

The slow-query log provides a record of which queries took a long time to execute, where "long" is defined by the value of the long_query_time server variable in seconds. Slow queries also cause the server to increment its Slow_queries status counter. The slow-query log can be useful for identifying queries that you might be able to improve if you rewrite them. However, you'll need to take general load into account when interpreting the contents of this log. Query time is measured in real time (not CPU time), so if your server is bogged down, it's more likely that a query will be assessed as being slow, even if at some other time it runs under the limit.

If you enable the slow-query log by specifying --log-slow-queries without a filename, the default name is HOSTNAME-slow.log in the data directory. If the --log-long-format option is given in conjunction with --log-slow-queries, MySQL also logs queries that execute without benefit of any index.

Because the time a query takes is not known until it finishes, queries are written to the slow-query log after they execute, not when they are received.

Use the mysqldumpslow utility to see what queries are contained in the slow-query log.

The Update Log

The update log is used to record statements that modify data, such as INSERT, DELETE, or UPDATE. SELECT statements are not written to this log. An UPDATE statement such as the following is not written to the update log, either, because it doesn't actually change any values:
Previous  Next  
Link Partners: Asia florist, Flowers to India, Hong kong flowers, Site submit, Cheap web hosting, China florist, Japan florist