DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Thomas has posted 33 posts at DZone. View Full User Profile

Log SQL Queries To Mysql (TABLE Storage)

  • submit to reddit
        Add the following lines in the MySQL configuration file (my.cnf or my.ini) to log the queries and the slow queries in a MySQL table: 
log-output = TABLE
long_query_time = 1
expire_logs_days = 1

Sample queries: 
select * from mysql.general_log order by event_time desc limit 10;
select * from mysql.slow_log order by start_time desc limit 10;