/var/log full because of very large mysqld.log file
search cancel

/var/log full because of very large mysqld.log file

book

Article ID: 106971

calendar_today

Updated On:

Products

CA API Gateway

Issue/Introduction

How to prevent the mysqld.log file to grow too large and fill up the /var/log?

Environment

Release:
Component: APIGTW

Resolution

To disable the logs, you would need to modify the my.cnf file
(see https://dev.mysql.com/doc/refman/5.7/en/error-log-unix.html and https://dev.mysql.com/doc/refman/5.7/en/mysqld-safe.html)

Another option would be to rotate the logs:
On a Linux (Red Hat) installation, you can use the mysql-log-rotate script for log maintenance. You can read more about the log maintenance on the MySQL documentation.


There is also the option to flush the log by this command:
#mysqladmin flush-logs
This will
- close any existing binlog files and open a new one with the next sequence number. You can then delete the old ones manually.
- it will close and reopen any other mysql log file. To force the creation of new files you will need to move the old files. For the /var/log/mysqld.log file you must manually create the new log file with the proper ownership after renaming the original log file
You can use the following set of commands:


shell> cd mysql-data-directory
shell> mv mysql.log mysql.old
shell> mv mysql-slow.log mysql-slow.old
shell> mv /var/log/mysqld.log /var/log/mysqld.log.old
shell> install -omysql -gmysql -m0644 /dev/null /var/log/mysqld.log

shell> mysqladmin flush-logs


After this you can backup and delete the old files. For more details, exceptions and background see also: https://dev.mysql.com/doc/refman/5.7/en/log-file-maintenance.html