wiki:mysql_query_logging
Table of Contents
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