When using triggers, if an update is done to a table then a trigger is executed. This is very convenient. But, what I would need is to execute an external script.
Is it possible to configure MySQL so that on a trigger/change of a value in a table an external process/script is executed?

  • So for every row update, an external application would be called? And if 4000 rows are updated, the application would be launched 4000 times? You think that would be wise? And if you had a million rows updated? Jan 19, 2014 at 1:28
  • Even if the update frequency is low, there are several other serious issues with such an approach. See: Catch-22 of the Active Database Jan 19, 2014 at 1:39
  • @ypercube:Interesting link.It is based on "triggers fire at the time of the operation, not the time of the commit". I was not aware of that.In this case it seems that triggers are useless in any case
    – Jim
    Jan 19, 2014 at 12:51
  • 1
    As simple example, I found this blog with an simple example: Call an external program form MySQL Trigger I found this example easy to understand. :) Best regards.
    – Vielinko
    Jul 31, 2014 at 20:13

1 Answer 1


It is possible, and it also makes for a security threat.

Anyway, to make that happen you would need to create (program, compile and install plugin) you own UDF - User Defined Function. It's a C/C++ code, so you can do anything you like in there.

  • Hi Shlomi, could I persuade you to elaborate on how UDF can make a security threat?
    – Morten
    Apr 14, 2016 at 7:09
  • 1
    @Morten I'll give you the extreme. Suppose the UDF call is this: SELECT EXECUTE_ON_BOX('rm -rf /important/data') and the UDF just accepts given string and executes it. Apr 17, 2016 at 7:59

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.