search cancel

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


Article ID: 106971


Updated On:


STARTER PACK-7 CA Rapid App Security CA API Gateway


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


Component: APIGTW


To disable the logs, you would need to modify the my.cnf file
(see and

Another option would be to rotate the logs:
you need to use a tool called logrotate, which is designed to ease administration of systems that generate large numbers of log files.
It allows automatic rotation, compression, removal, and mailing of log files. Each log file may be handled daily, weekly, monthly, or when it grows too large.
With this tool you keep logs longer with less disk space.

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: