2

I want to share a discovery that has helped me a lot. This is the plugin for MySQL UDF which can run bash scripts and commands from MySQL. In my case it was very interesting to create triggers associated with a particular table.

  • Download from : https://github.com/mysqludf/lib_mysqludf_sys/archive/master.zip
  • Open the folder and edit Makefile:
  • We will install some compilation tools
  • sudo apt-get install build-essential
  • sudo apt-get install libmysqlclient15-dev
  • If you can not install the latest tool from the repository, do sudo apt-get update to update them.
  • Add -fPIC In the command gcc to compile the plugin us.
  • Modify LIBDIR variable to point to your mysqld plugins folder, usually:
  • LIBDIR = / usr / lib / mysql / plugin

  • make

  • ./Install.sh.
  • Already installed but disabled. To enable:
  • sudo Ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
  • sudo Apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
  • to verify the installation, you can run from the MySQL console:

    SELECT sys_eval ("id")

  • if it returns something like:

    uid = 122 (mysql) gid = 130 (mysql) groups = 130 (mysql)

    the installation is successful

I hope you find it useful.

References:

http://dev.mysql.com/doc/refman/5.7/en/faqs-triggers.html#qandaitem-23-5-1-11

http://jawtech.com/drupal7/?q=content/how-create-mysql-triggers-execute-external-scriptphp-ubuntu-server-14

5
  • There is a simple way to execute a shell command from MySQL console: \! command Commented Oct 13, 2016 at 16:01
  • is not the same. With \! <command> syntax you escape the command and run it from the bash interpreter, but you can not use this syntax within a trigger or procedure, but is useful on many occasions. Commented Oct 13, 2016 at 18:31
  • 1
    I’m voting to close this question because it isn't a question, but an answer. Commented Jul 13, 2021 at 15:22
  • 1
    No need for a plugin, here's a simple example support.pubnub.com/hc/en-us/articles/… Commented Sep 2, 2022 at 11:28
  • I’m voting to close this question because it's not a question. It should be an answer, or a blog post on another site. Commented Sep 24, 2024 at 13:15

0

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.