How to read a mysql binlog

user4930867 picture user4930867 · Jun 3, 2015 · Viewed 22.8k times · Source

I want to write a service to tail the mysql bin log to get notifications about database changes.

Is there an open source library that reads and parses mysql bin log in ROW format?

Answer

Tan Hong Tat picture Tan Hong Tat · Jun 3, 2015

Use mysqlbinlog.

The server's binary log consists of files containing “events” that describe modifications to database contents. The server writes these files in binary format. To display their contents in text format, use the mysqlbinlog utility. You can also use mysqlbinlog to display the contents of relay log files written by a slave server in a replication setup because relay logs have the same format as binary logs.

Source: https://dev.mysql.com/doc/refman/5.6/en/mysqlbinlog.html