Difference between revisions of "Enable MySQL’s slow query log without a restart"
From MyWiki
(Created page with "Log on to mysql as root <br> Set the log-file location for the Slow Query log. Make sure mysql has write permission. mysql> SET GLOBAL slow_query_log_file = '/path/to/slow_qu...") |
|||
Line 2: | Line 2: | ||
Set the log-file location for the Slow Query log. Make sure mysql has write permission. | Set the log-file location for the Slow Query log. Make sure mysql has write permission. | ||
mysql> SET GLOBAL slow_query_log_file = '/path/to/slow_query.log'; | mysql> SET GLOBAL slow_query_log_file = '/path/to/slow_query.log'; | ||
+ | Determine what makes a query "slow", by setting the limit (in seconds) after which a query is logged to the slow query log. The example below logs every query that exceeds 10 seconds in duration.<br> | ||
+ | mysql> SET GLOBAL long_query_time = 10; |
Revision as of 08:36, 18 May 2016
Log on to mysql as root
Set the log-file location for the Slow Query log. Make sure mysql has write permission.
mysql> SET GLOBAL slow_query_log_file = '/path/to/slow_query.log';
Determine what makes a query "slow", by setting the limit (in seconds) after which a query is logged to the slow query log. The example below logs every query that exceeds 10 seconds in duration.
mysql> SET GLOBAL long_query_time = 10;