Project:MySQL: Difference between revisions

From MaRDI portal
Created page with "== Heading text == How to use the slow query log Set the slow query log to "on", by doing one of these things: For a permanent solution, edit `my.cnf` and set: slow_query_log = 1 slow_query_log_file = /var/lib/mysql/slow.log long_query_time = 1 #your time in seconds, the lower it is, the more will be logged For a temporary solution, log in to mysql as root and execute: SET GLOBAL slow_query_log = 'ON'; SET GLOBAL slow_query_log_file = '/var/lib/mysql/slow.log'; SET GLOBA..."
 
No edit summary
Line 1: Line 1:
== Heading text ==
== How to use the slow query log ==
How to use the slow query log
Set the slow query log to "on", by doing one of these things:
Set the slow query log to "on", by doing one of these things:
For a permanent solution, edit `my.cnf` and set:
 
slow_query_log = 1
* For a permanent solution, edit ''my.cnf'' and set:
slow_query_log_file = /var/lib/mysql/slow.log
** slow_query_log = 1
long_query_time = 1 #your time in seconds, the lower it is, the more will be logged
** slow_query_log_file = /var/lib/mysql/slow.log
For a temporary solution, log in to mysql as root and execute:
** long_query_time = 1 ''#your time in seconds, the lower it is, the more will be logged''
SET GLOBAL slow_query_log = 'ON';
* For a temporary solution, log in to mysql as root and execute:
SET GLOBAL slow_query_log_file = '/var/lib/mysql/slow.log';
** SET GLOBAL slow_query_log = 'ON';
SET GLOBAL long_query_time = 1;  #your time in seconds, the lower it is, the more will be logged
** SET GLOBAL slow_query_log_file = '/var/lib/mysql/slow.log';
** SET GLOBAL long_query_time = 1;  ''#your time in seconds, the lower it is, the more will be logged''
 
Leave it running as long as desired.
Leave it running as long as desired.
Then, go to location of slow log file and run  
 
mysqldumpslow ./slow.log  
Then, go to location of slow log file and run ''mysqldumpslow ./slow.log'' to get a summary of the queries.
to get a summary of the queries.

Revision as of 14:31, 28 October 2024

How to use the slow query log

Set the slow query log to "on", by doing one of these things:

  • For a permanent solution, edit my.cnf and set:
    • slow_query_log = 1
    • slow_query_log_file = /var/lib/mysql/slow.log
    • long_query_time = 1 #your time in seconds, the lower it is, the more will be logged
  • For a temporary solution, log in to mysql as root and execute:
    • SET GLOBAL slow_query_log = 'ON';
    • SET GLOBAL slow_query_log_file = '/var/lib/mysql/slow.log';
    • SET GLOBAL long_query_time = 1; #your time in seconds, the lower it is, the more will be logged

Leave it running as long as desired.

Then, go to location of slow log file and run mysqldumpslow ./slow.log to get a summary of the queries.