6

My question is how to stop logs on mysql

log_error = /var/log/mysql/error.log i have commented already.

with slow queries too. But i have one more log file in /var/lib/mysql/hostname.log with hostname I mean that for example I am on server called hulk so the log will be hulk.log and so on. In that log are all queries. So the log is growing really fast and also is really big. So my question is how to disable this log ?

1
  • Why would you want to stop logging? What happens if you need to track down some error?
    – mdpc
    Jan 26, 2013 at 1:45

4 Answers 4

12

If you would like to dynamically stop logging, login as root@localhost and run this:

SET GLOBAL general_log = 'OFF';

That's it. No restart of mysql needed.

If you are not root@localhost, you will need to be logged in as a user with SUPER privilege.

2
  • thx man it is works ;)
    – nonus25
    Jan 26, 2013 at 21:55
  • 1
    it doesn't disable error log for me !!!
    – Jerry Chin
    Oct 21, 2017 at 4:11
3

In MySQL 5.1.12+ add/change this in your my.cnf

general-log = 0

In MySQL 5.1.11- remove this in your my.cnf

log

or

log = 

Source:

http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_general_log

http://dev.mysql.com/doc/refman/5.1/en/server-options.html#option_mysqld_log

2
  • 1
    general-log = 0 works fine, but on master I cant do restart so I disable logs like RolandoMySQLDBA said. But on slaves I tries your way and is working also thx
    – nonus25
    Jan 26, 2013 at 21:59
  • 1
    In MySQL 5.5.49 , the entry is general_log = 0
    – Raptor
    Jun 3, 2016 at 7:56
0

vim /etc/my.cnf

There are two lines you want to comment out:

log=...
log-error=...

Restart mysql by

service mysql restart

or

service mysqld restart

Logging will be turned off now. Reverse the process when you want to turn it back on (if you do...) :)

0

Generally you would want to keep logs (or better yet, ship off to a log-aggregation service), and also apply logrotate to the local log files.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .