Solved

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

Posted on 2012-03-26
2
426 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SSL/TLS - openssl troubleshooting 3 62
Redhat upgrade 1 48
PHP: Filling Out/Creating a PDF 29 107
Building a glossary into your website 9 22
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

733 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