Search code examples
mysqlmysqlbinlog

Can we enable mysql binary logging for a specific table


I want to write a listener which detects the DML changes on a table and perform some actions. This listener cannot be embedded in the application and it runs separately.

I thought let the application write to blackhole table and I will detect the changes from the binary log file.

But in the docs I found that enabling binary logging slows down the mysql performance slightly. Thats why i was wondering is there a way i can make the mysql master to log the changes related to a specific table.

Thanks!


Solution

  • SQL is the best way to track DML change and call function based on that. But, as you want to explore other options you may try

    1. writing a cronjob with General Query Log which includes SELECT / SHOW statements as well which you don't need

    2. mysqlbinlog : It slows down performance just a little, but it is necessary for point in time data recovery and replication.

    Suggestions:

    • On a prod environment, MySQL binary log must be enabled. and general query log must be disabled as general query logs almost everything and gets filled very quickly and might run out of disk space if not rotated properly.
    • On a dev/qa environment, general query log can be enabled with proper rotation policy.