我想删除mysql.general_log
表中的旧行但遇到此错误:
#1556 - You can't use locks with log tables.
这是我跑的查询:
DELETE FROM `general_log` WHERE `event_time` < "2014-01-25 14:05"
答案 0 :(得分:17)
您可以重命名表格,根据需要执行清理,然后再次恢复表格名称。
示例:
SET GLOBAL general_log = 'OFF';
RENAME TABLE general_log TO general_log_temp;
DELETE FROM `general_log_temp` WHERE `event_time` < DATE(NOW());
RENAME TABLE general_log_temp TO general_log;
SET GLOBAL general_log = 'ON';