Create triggers with MySQL procedures

Angry developer

Angry developer

I wrote some SQL procedures, which can create triggers. The main goal was to create triggers for `mysql` schema, but it is not possible for the following limitation of current version MySQL and MariaDB:

1465 HY000 ER_NO_TRIGGERS_ON_SYSTEM_SCHEMA Triggers can not be created on system tables

Facepalm.  I don’t know about this limitation before. But somebody maybe finds this procedures usefull for replicating other tables/schemas. It is released as Open Source and repository is available on github.

Installation is simple:

git clone
cd mysql-replicate-by-triggers
make install

This will create procedures in `repl` schema. Then you can create triggers with the following command:

echo 'CALL repl_init("srcdb", "dstdb")' | mysql "repl" | mysql "repl"

It is workaround for another limitation: you can’t create trigger in procedure.