Tuesday 8 December 2015

Enable logs from MySQL configuration


All log files are NOT enabled by default MySQL setup.

The Error Log

Error Log goes to syslog due to,

cat /etc/mysql/conf.d/mysqld_safe_syslog.cnf
[mysqld_safe]
syslog

vi /etc/mysql/my.cnf
[mysqld_safe]
log_error=/var/log/mysql/error.log

[mysqld]
log_error=/var/log/mysql/error.log

The General Query Log

To enable General Query Log,

vi /etc/mysql/my.cnf
general_log_file        = /var/log/mysql/mysql.log
general_log             = 1

The Slow Query Log

To enable Slow Query Log,

vi /etc/mysql/my.cnf
log_slow_queries       = /var/log/mysql/mysql-slow.log
long_query_time = 2
log-queries-not-using-indexes

Error Log file = /var/log/mysql/error.log
General Query Log file = /var/log/mysql/mysql.log
Slow Query Log file = /var/log/mysql/mysql-slow.log


Ref :- https://dev.mysql.com/doc/refman/5.6/en/server-logs.html
          http://www.pontikis.net/blog/how-and-when-to-enable-mysql-logs

No comments:

Post a Comment