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

How to compile and install opencv under ubuntu

Easy installation of opencv2: conda install --cha...

Detailed installation steps for MySQL 8.0.11

This article shares the installation steps of MyS...

Detailed explanation of samba + OPENldap to build a file sharing server

Here I use samba (file sharing service) v4.9.1 + ...

How to deploy Go web applications using Docker

Table of contents Why do we need Docker? Docker d...

Web project development JS function anti-shake and throttling sample code

Table of contents Stabilization Introduction Anti...

10 excellent Web UI libraries/frameworks

1. IT Mill Toolkit IT Mill Toolkit is an open sou...

How to install jupyter in docker on centos and open ports

Table of contents Install jupyter Docker port map...

jQuery implements the drop-down box for selecting the place of residence

The specific code for using jQuery to implement t...

Summary of common docker commands

Docker installation 1. Requirements: Linux kernel...

How to deploy k8s in docker

K8s k8s is a cluster. There are multiple Namespac...

Appreciation of the low-key and elegant web design in black, white and gray

Among classic color combinations, probably no one...

A brief analysis of the basic concepts of HTML web pages

What is a web page? The page displayed after the ...

How to generate a unique server-id in MySQL

Preface We all know that MySQL uses server-id to ...

Detailed explanation of three ways to cut catalina.out logs in tomcat

1. Log4j for log segmentation 1) Prepare three pa...

Sample code using vue-router in html

Introducing vue and vue-router <script src=&qu...