How to enable MySQL Query Log?

后端 未结 14 1392
渐次进展
渐次进展 2020-11-22 09:38

How do I enable the MySQL function that logs each SQL query statement received from clients and the time that query statement has submitted? Can I do that in phpmyadmin or N

14条回答
  •  渐次进展
    2020-11-22 10:16

    Take a look on this answer to another related question. It shows how to enable, disable and to see the logs on live servers without restarting.

    Log all queries in mysql


    Here is a summary:

    If you don't want or cannot restart the MySQL server you can proceed like this on your running server:

    • Create your log tables (see answer)

    • Enable Query logging on the database (Note that the string 'table' should be put literally and not substituted by any table name. Thanks Nicholas Pickering)

    SET global general_log = 1;
    SET global log_output = 'table';
    
    • View the log
    select * from mysql.general_log;
    
    • Disable Query logging on the database
    SET global general_log = 0;
    

提交回复
热议问题