9

I'm using a WAMP server with phpmyadmin and MySQL 5.0. I've been looking for a way to only log all insert, update and delete queries, to no avail though.

I did manage to get it to auto generate logs adding the "log=C:\wamp\mysql\log\queries.log" line to the my.ini configuration file of mysql, but the log didn't log the exact queries.

What i'm trying is that, whenever an insert, delete or update query happens, it logs the query in a file or in another table. Is this possible with procedures? What are my choices?

2 Answers 2

7

This is achieved through the Binary Log . You enable it using the log-bin parameter.
You can read the contents of a binary log using this utility, the mysqlbinlog .

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks, this is what I needed. Other than the mysqlbinlog, are there other ways to read the log file? Like, Java can write/read binary files, will it read the log properly as well?
I gueess you can, but mysqlbinlog has many parsing features, such as <a href="dev.mysql.com/doc/refman/5.0/en/…" target="_blank">start-datetime</a> which lets you select the starting date & time of statements to display.
I personally found the output of mysqlbinlog hard to read. Reading the general log was much more helpful, after filtering out SELECT queries.
2

There is a workaround. You can pass the tail's output to grep, e.g. like this:

tail -f /var/log/mysql/mysql.log | grep "update "

1 Comment

This only works if the general log has been enabled, right?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.