[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to do Log rotation and set max log file size policy in mysql ?

Posted on 2012-03-26
2
Medium Priority
?
439 Views
Last Modified: 2012-04-11
I know how to enable log for mysql:
i insert the following line in /etc/my.cnf:
log=/datalogs/mysql.log

But how to configure mysql for log rotation and to set the max size for the same?

Is it possible to set that only teh update,insert and delete commands be logged ... i dont want to log select queries.
0
Comment
Question by:pvinodp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 24

Accepted Solution

by:
johanntagle earned 2000 total points
ID: 37768785
Use the binary logs (http://dev.mysql.com/doc/refman/5.1/en/binary-log.html) for logging only DML statements.  The log is not readily readable (it is binary) but it's easy to process using the mysqlbinlog utility.  An added benefit is you can use them to update a backup to point of failure in case you encounter problems (see http://dev.mysql.com/doc/refman/5.1/en/point-in-time-recovery.html).  

In you my.cnf:

log-bin = /path/to/where/you/want/your/logs/prefix

(everything after "log-bin" is optional.  documentation says "If no base_name value is given, the default name is the value of the pid-file option (which by default is the name of host machine) followed by -bin")

You set size limit via:

max_binlog_size = <size_in_bytes>

I don't know of an actual log rotation functionality in mysql, but you can set logs to expire via:

expire_logs_days = <number_in_days>

Hope this helps
0
 

Author Closing Comment

by:pvinodp
ID: 37836079
THanks for pointing to binary logs. Also you can set the database for which you need the logs for. This is helpful in case you have multiple database in your mysql server.
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Fine Tune your automatic Updates for Ubuntu / Debian
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question