Technology Insights

Configure Logrotate To Rotate And Flush MySQL Logs Without A Password

If you have the resources (CPU + RAM) available on your server then its can be a great troubleshooting tool if you enable MySQL logging which includes server messages, SQL query logs, and slow query logs. If you do not have the resources I would suggest only enable minimal logging such as only server messages and the slow query log since enabling all queries to be written to a file can become expensive rather quickly. Below I discuss enabling three different types of MySQL logging, adding a MySQL configuration file to logrotate, and configuring root to run mysqladmin commands without having to type the password out each time.

Technology Errors

[ERROR] Could not use /var/log/mysql-err.log for logging (error 13)

081004  2:35:11 [ERROR] Could not use /var/log/mysql-err.log for logging (error 13). Turning logging off for the whole duration of the MySQL server process. To turn it on again: fix the cause, shutdown the MySQL server and restart it.

The above error displayed in the mysqld.log file fter adding the below line to /etc/my.cnf under [mysqld].


Before restarting mysql I created the file and applied the proper permissions by entering the commands below from the console.