• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 537
  • Last Modified:

How to control the size of mysql log ?

##########################################################
[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?
0
pvinodp
Asked:
pvinodp
  • 3
  • 3
  • 2
  • +1
1 Solution
 
mrjoltcolaCommented:
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?
0
 
pvinodpAuthor 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...
0
 
mrjoltcolaCommented:
Which MySQL version?
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
pvinodpAuthor Commented:
mysql server verson 5.0
0
 
mrjoltcolaCommented:
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)
0
 
wesly_chenCommented:
> 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.
0
 
underskyCommented:
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.
0
 
underskyCommented:
oh >_< non daily...


/var/log/mysql.log {
      hourly
      nomissingok
      rotate 10
      compress
      delaycompress
      notifempty
}
0
 
pvinodpAuthor Commented:
Works... but i expected a solution which contains details in changinf my.cnf
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 3
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now