8i | 9i | 10g | 11g | 12c | 13c | 18c | Misc | PL/SQL | SQL | RAC | WebLogic | Linux

Home » Articles » Mysql » Here

MySQL : Managing Log Files

This article describes how to manage (delete or purge) log files associated with MySQL.

Related articles.

Binary Logs

Setting the EXPIRE_LOGS_DAYS parameter in the "/etc/my.cnf" file can be used to manage old binary log files, but you will probably want to manage them as part of your backup schedule.

One slight complication to this is you should keep the contents of the index file consistent with the contents of the log_bin directory. This can be done using the PURGE BINARY LOGS command, but that requires you to know the name of the binary log to purge up to.

PURGE BINARY LOGS TO '<binary-log-name>';

There is an example of how to manage binary logs as part of a backup schedule here.

mysqld.log

The simplest way to maintain the "mysqld.log" file on linux is to use the logrotate functionality.

Amend "/etc/logrotate.d/mysql" file, making the contents look as follows.

/var/log/mysqld.log {
        copytruncate 644 mysql mysql
        daily
        rotate 7
        compress
    postrotate
        # Nothing to do here.
    endscript
}

A brief explanation of the settings is shown below.

For more information see:

Hope this helps. Regards Tim...

Back to the Top.