User Tools

Site Tools


wiki:mysql_query_logging

mysql query logging

On mysql command line

SET global general_log_file='/var/log/mysql/my_query_log.log'; SET global general_log = on; SET global log_output = 'file';

When finished turn it off

SET global general_log = off;

Slow queries

1. Check and enable query logging

show variables like 'general_log%';
SET global general_log = 1; 

2. wait some time

SET global general_log = 0;
grep 'Query' /var/lib/mysql/my_query_log.log | sed -e 's/.* Query//' | sort | uniq -c | sort -rn | less

Tested on

  • 5.5.60-38.12 Percona Server

See also

References

wiki/mysql_query_logging.txt · Last modified: 2021/04/29 16:53 by antisa

Except where otherwise noted, content on this wiki is licensed under the following license: CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki