Article posted on : link to source

MySQL Server generates several logs that can help you monitor the activities of the server. However, once these logs are enabled, they can grow in size and start taking up too much disk space. This is why it’s important to have an automated way of archiving and preserving MySQL log files for a certain duration, as well as deleting the old ones. In this blog post, we describe some best practices for setting up and managing MySQL error logs, general logs and slow query logs for your MySQL deployments.

Setting Up MySQL Server Logging

Let’s look at how to setup the following 3 types of logs:

Error Log

Logs all the problems encountered during starting, running, or stopping mysqld. This log can be enabled by having the following option in /etc/my.cnf file:

log_error=/var/log/mysql/mysqld.log

General Query Log

Logs established client connections and statements received from clients. This log can be enabled by having the following option in /etc/my.cnf file:

general_log=ON
general_log_file=/var/log/mysql/general.log

Slow Query Log

Logs queries that took more than long_query_time seconds to execute. This log can be enabled by the following option in /etc/my.cnf file:

slow_query_log=ON
slow_query_log_file=/var/log/mysql/mysql-slowquery.log

Setting Up Criteria For Log Rotation

As an example, let’s have some criteria for managing general MySQL query logs. We can come up with a suitable set of criteria for log …

Read More on Datafloq

%d bloggers like this: