开发者

MySQL - Transaction Logging - binlog? general query log? log to database?

开发者 https://www.devze.com 2023-02-14 12:26 出处:网络
We would like to turn on query logging so we can find queries that change data. It it possible to do transaction logs to a database?

We would like to turn on query logging so we can find queries that change data.

It it possible to do transaction logs to a database? what is the difference between binlog and the general query开发者_StackOverflow社区 log?


If enabled, the binary log includes all queries that modify data. But you should be aware of the format. It's stored in binary format, so you need to convert it to get the actual SQL. Also, if you're using row-based replication with MySQL 5.1 or later, then you may not be able to get the actual SQL statements that ran.

The general query log includes all queries, even SELECTs that do not modify data.

You should take a look at mk-query-digest, which offers several different ways to monitor queries.


binlog is used to record all the changes happening in a database. Main uses of bin log is to do replication (Keep other copies of database up-to-date) and backup. You can retrieve all the write queries from binlog using mysqlbinlog utility.

General query log is used mainly for server debigging or slow query monitoring.

For your use case you can enable bin log with statement mode

0

精彩评论

暂无评论...
验证码 换一张
取 消