Is there a way to watch a mysql database for changes using perl?

后端 未结 3 447
一个人的身影
一个人的身影 2021-01-05 10:26

I\'m looking for a solution similar to the inotify method of watching files for changes. I\'m aware that I could watch the binlog file of the mysql database and run queries

3条回答
  •  Happy的楠姐
    2021-01-05 11:11

    If you add a TRIGGER to the table(s) you're interested in, you can use that to alert the watching application. You could do that in a number of ways:

    1. Create an audit table in the database, and have the trigger write the relevant info there; and have your watching application poll the audit table for new entries. You're still polling, but in a controlled way which won't hit the server too hard.
    2. Have the trigger call an external app through a UDF.

提交回复
热议问题