2

I’m managing a production MySQL server running on a VM, and I just discovered that the general_log.CSV file in /var/lib/mysql/mysql/ has grown to 47GB, consuming almost 70% of the disk space.

Here’s the output of du -sh /var/lib/mysql/mysql/*:

8.0K /var/lib/mysql/mysql/general_log_213.sdi 4.0K /var/lib/mysql/mysql/general_log.CSM 47G /var/lib/mysql/mysql/general_log.CSV 16K /var/lib/mysql/mysql/slow_log_214.sdi 4.0K /var/lib/mysql/mysql/slow_log.CSM 0 /var/lib/mysql/mysql/slow_log.CSV 

Since this is a production environment, I need a safe way to free up space without affecting MySQL operations.

Questions:

  • Is it safe to delete or truncate general_log.CSV in a live production database?
  • What is the recommended way to clear this log without disrupting MySQL?
  • what is the purpose of that file

1 Answer 1

3

/var/lib/mysql/mysql/general_log.csv is the MySQL general log. It contains general server activity e.g. client connections.

You can truncate it via the command:

cat /dev/null > /var/lib/mysql/mysql/general_log.CSV 

It is safe to run this command with the server running, but if that doesn't free up the space, it means that the server is holding the file open and you would have to restart the mysqld daemon, which would reset the connections of the clients to the database.

To disable the general log definitely, comment out the general_log line in the MySQL configuration file (usually /etc/mysql/my.cnf) and force the MySQL server to reload its configuration.

2
  • I checked the general_log now it is disabled , so running cat /dev/null > /var/lib/mysql/mysql/general_log.CSV will free the space?? Commented Feb 11 at 9:46
  • Yes, that's what I wrote. Commented Feb 11 at 15:11

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.