Summary of Methods for Cleaning Mysql general_log
- 2021-12-13 17:25:24
- OfStack
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_log2 deletes table data, it is found that the data file of the operating system still exists. You need to delete the data file manually before continuing 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 the file of general_log to execute
cat /dev/null > general_log.csv
The discovery also released the size, much faster than the previous one
Method 3:
You can add in the configuration file my. conf:
general_log=1
general_log_file='/data/mysql/general_log.CSV'
Put files on a larger disk
The above is all the knowledge points introduced this time. Thank you for your study and support for this site.