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
Solved

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

Posted on 2012-03-26
2
425 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
2 Comments
 
LVL 24

Accepted Solution

by:
johanntagle earned 500 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

809 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