Last active
November 29, 2016 08:59
-
-
Save febridev/6f895ed7b8c7ac72592241430ecd4a2e to your computer and use it in GitHub Desktop.
Setup MySQL Log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
step1: Go to this file(/etc/mysql/conf.d/mysqld_safe_syslog.cnf) and remove or comment those line. | |
step2: Go to mysql conf file(/etc/mysql/my.cnf ) and add following lines | |
To enable error log add following | |
[mysqld_safe] | |
log_error=/var/log/mysql/mysql_error.log | |
[mysqld] | |
log_error=/var/log/mysql/mysql_error.log | |
To enable general query log add following | |
general_log_file = /var/log/mysql/mysql.log | |
general_log = 1 | |
To enable Slow Query Log add following | |
log_slow_queries = /var/log/mysql/mysql-slow.log | |
long_query_time = 2 | |
log-queries-not-using-indexes | |
step3: save the file and restart mysql using following commands | |
service mysql restart | |
To enable logs at runtime, login to mysql client (mysql -u root -p ) and give: | |
SET GLOBAL general_log = 'ON'; | |
SET GLOBAL slow_query_log = 'ON'; | |
Finally one thing I would like to mention here is I read this from a blog. Thanks. It works for me. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment