We help IT Professionals succeed at work.

How to control the size of mysql log ?

pvinodp
pvinodp asked
on
Medium Priority
543 Views
Last Modified: 2012-05-11
##########################################################
[mysqld]
datadir=/var/lib/ipaccess/data/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
log=/var/log/mysql.log

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[mysqld]
default_storage_engine=InnoDB
##########################################################


Above is the content of my.cnf file.

The problem is that it is increasing exponentially.. I want to control it.
How do I do it?
Comment
Watch Question

Top Expert 2009

Commented:
Can you explain how you mean it is increasing exponentially?

How fast does it grow in a 24 hour period?

Can you show what sort of errors / info is in the log?

Author

Commented:
It grew to more than 12.1 M within 15 minutes. It is a server sstem where we use for system testing.
It has all the log, whatever is executed on teh mysql server.
I mean all operations...
Top Expert 2009

Commented:
Which MySQL version?

Author

Commented:
mysql server verson 5.0
Top Expert 2009

Commented:
I assume this is the general query log since you can see the statements in plaintext. You can disable this by changing your startup command for mysqld.

See this for 5.0 directions: http://dev.mysql.com/doc/refman/5.0/en/query-log.html

Essentially I believe you want to remove the --log or -l from the startup script.

On Linux, I believe you'll go to /etc/init.d/mysql startup script and edit it there. Then restart (/etc/init.d/mysql restart)
Top Expert 2011

Commented:
> old_passwords=1
> log=/var/log/mysql.log
Edit /etc/my.cnf, and change to
--------------
old_passwords=1
log-error=/var/log/mysql-error.log  # Error log only
-------------

You only care about the error log, not the query log.

After the change, restart the mysql service.
Dmitriy SkyIT Engeneer

Commented:
you can control your logs by put it in logrotate, most of all distributions have it

just create something like this:
/etc/logrotate.d/mysql


/var/log/mysql.log {
      daily
      nomissingok
      rotate 10
      compress
      delaycompress
      notifempty
}


then copy logrotate sh into cron.hourly

mv /etc/cron.daily/logrotate /etc/cron.hourly/logrotate

so this will start logrotation every hour, gzip old logs, and remove veryold

but best way is check, what's problem is, best check what exactly into mysql.log fill it so fast.
IT Engeneer
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Works... but i expected a solution which contains details in changinf my.cnf
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.