Clean up MySQL general_ Summary of log method

Time:2020-10-18

Method 1


SET GLOBAL general_log = 'OFF';
RENAME TABLE mysql.general_log TO mysql.general_log2;
DELETE FROM mysql.general_log2;

Note: when delete from mysql.general_ When log2 executes the deletion of table data, it is found that the data file of the operating system still exists. You need to manually delete the data file, and then continue with the following data operation steps


OPTIMIZE TABLE general_log2;
RENAME TABLE mysql.general_log2 TO mysql.general_log;
SET GLOBAL general_log = 'ON';

This method takes a long time

Method 2


SET GLOBAL general_log = 'OFF';

Find general_ Log file execution


cat /dev/null > general_log.csv

The discovery also released the size, much faster than the previous one

Method 3

Can be found in the configuration file my.conf Add:


general_log=1
general_log_file='/data/mysql/general_log.CSV'

Put the file on a larger disk

The above is the introduction of all knowledge points, thank you for your learning and support for developeppaer.

Recommended Today

Common environment construction of centos7

It’s very painful to set up a variety of environments every time, and encounter various problems. Therefore, write this article to record the construction process, problems and solutions of some environments under centos7. The construction of other environments will also be updated. This article is not worth reading, but can be collected, has been prepared […]