Summary of methods for cleaning Mysql general_log

Summary of methods for cleaning Mysql general_log

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 is executed to delete table data, it is found that the operating system data file 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 the general_log file and execute

cat /dev/null > general_log.csv

I found that the size was also released, which was much faster than the previous one.

Method 3:

You can add it to the configuration file my.conf:

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

Put the file on a larger disk

The above is all the knowledge points introduced this time. Thank you for your learning and support for 123WORDPRESS.COM.

You may also be interested in:
  • Detailed explanation of MySQL database binlog cleanup command
  • How to quickly clean up billions of data in MySQL database
  • Code for automatically backing up and cleaning up MySQL database using batch processing
  • How to clean up Alibaba Cloud MySQL space
  • How to completely delete the MySQL service (clean the registry)
  • Two ways to correctly clean up mysql binlog logs
  • How to automatically clean up MySQL binlog logs
  • Shell script automatically backs up MySQL to FTP and regularly cleans up expired backups
  • Analyze the causes and cleanup of fragmentation in MySQL tables
  • PHP data is cleaned before storage. Note that the value range of PHP intval is different from that of MySQL int.
  • How to clean up data in MySQL online database

<<:  A brief talk about JavaScript parasitic composition inheritance

>>:  Linux echo text processing command usage and examples

Recommend

10 key differences between HTML5 and HTML4

HTML5 is the next version of the HTML standard. M...

React implements the expansion and collapse function of complex search forms

Give time time and let the past go. In the previo...

MySQL database rename fast and safe method (3 kinds)

Table of contents How to rename MySQL database Th...

Pure HTML+CSS to achieve typing effect

This article mainly introduces the typing effect ...

Vue uses ECharts to implement line charts and pie charts

When developing a backend management project, it ...

About Vue virtual dom problem

Table of contents 1. What is virtual dom? 2. Why ...

js implements mouse switching pictures (without timer)

This article example shares the specific code of ...

IE6 BUG and fix is ​​a preventive strategy

Original article: Ultimate IE6 Cheatsheet: How To...

Solution to 1045 error in mysql database

How to solve the problem of 1045 when the local d...

MySQL 5.7 installation and configuration tutorial under CentOS7 64 bit

Installation environment: CentOS7 64-bit MINI ver...

In-depth study of MySQL composite index

A composite index (also called a joint index) is ...

An example of using CSS methodologies to achieve modularity

1. What are CSS methodologies? CSS methodologies ...