I have a classical statement-based replication between the master and the slave. Triggers were created on the master and replicated on the slave as well.

Assuming that I have, say an ON UPDATE trigger, is the following correct?

MySQL will only write to the binary log statements that were not the result of the trigger. Data consistency between the master and the slave is therefore ensured by the fact that the same triggers are present on both.

The relevance of this pertains to incremental updates (or accumulutors), eg.

CREATE TRIGGER vesion_increment AFTER UPDATE ON table
  UPDATE table SET version=version+1;

In this case, the UPDATE table SET version=version+1 will not be in the binary log and hence not replicated but taken care of by the same trigger on the slave. Is that correct?

1 Answer 1


Yes, you are correct. You can often get bitten from the fact that the triggers are missing on the slave and thus the trigger effects are not there.

Also if the triggers use any routines (PROCEDUREs and FUNCTIONs) you have to make sure they are present on the slave too. The latter might bite you if you provision your slaves from a mysqldump, since by default mysqldump does not dump routines.

  • "When using row-based replication, triggers on the slave are not activated by statements originating on the master." -- see manual.
    – Rick James
    Commented Apr 10, 2015 at 17:52
  • Thanks, @RickJames. But you're quoting the manual for row based replication and I'm in a statement based setting. Moreover, my question states the opposite of your comment, ie. that triggers ON the master are not written to the log AND data integrity is therefore ensured by the presence of said triggers on the slave.
    – VH-NZZ
    Commented May 9, 2015 at 6:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.