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-essentialsudo apt-get install libmysqlclient15-dev- If you can not install the latest tool from the repository, do
sudo apt-get updateto update them. - Add
-fPICIn the command gcc to compile the plugin us. - Modify LIBDIR variable to point to your mysqld plugins folder, usually:
LIBDIR = / usr / lib / mysql / pluginmake./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.mysqldto 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
\! command