Search code examples
mysqlmysql-workbenchmysql-slow-query-log

How to flush data from mysql.slow_log table in mysql?


Hi i am working on MySQL version 5.5, can somebody please help me to clear/flush data from mysql.slow_log tables in mysql ?


Solution

  • If you are on linux

    > mysql -uroot -p
    > enter your password
    > use mysql;
    > delete from slow_log;
    

    It will give you an error that you can't lock log tables. Work around is, run the following queries:

    SET GLOBAL slow_log= 'OFF';
    RENAME TABLE slow_log TO general_log_temp;
    DELETE FROM `general_log_temp`;
    RENAME TABLE general_log_temp TO slow_log ;
    SET GLOBAL slow_log = 'ON';
    

    Taken from "DELETE old rows from Mysql General Log Table"

    Update:

    You can truncate the table like TRUNCATE mysql.slow_log as mentioned by Renato Liibke