简体   繁体   中英

MySQL - Transaction Logging - binlog? general query log? log to 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 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM