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

Vikrant More picture Vikrant More · Mar 20, 2015 · Viewed 8.4k times · Source

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 ?

Answer

jmsb picture jmsb · Mar 8, 2016

You can avoid locking problems without disabling the slow log by using the built-in rotate function:

CALL mysql.rds_rotate_slow_log;
DELETE FROM mysql.slow_log_backup;

This will swap the 'slow_log' and 'slow_log_backup' tables, moving all of the data you want to clear to the non-locked 'slow_log_backup' table, which will happily take the DELETE FROM for data purging purposes.

You can also just invoke rotation twice:

CALL mysql.rds_rotate_slow_log;
CALL mysql.rds_rotate_slow_log;