Search code examples
mysqlloggingconfiguser-management

Mysql slow.log user specific


I use a slow.log logging on my MySQL server to catch bottlenecks in my scripts, but at the same time I use phpmyadmin on this server. My scripts and phpmyadmin has different MySQL user accounts and now, when I analyzing the slow.log file, I see a lot of spam from phpmyadmin queries, is it possible, to configure the MySQL to logging a slow queries only from specific users?


Solution

  • If using MySQL 5.6, you can use the performance schema, and look at the different statements summaries there.

    There are summaries by account (someuser@somehost), by username alone (someuser) or by host alone (somehost).

    See the following tables:

    • performance_schema.events_statements_summary_by_account_by_event_name
    • performance_schema.events_statements_summary_by_user_by_event_name
    • performance_schema.events_statements_summary_by_host_by_event_name
    • performance_schema.events_statements_summary_global_by_event_name

    http://dev.mysql.com/doc/refman/5.6/en/performance-schema.html