How to execute an external script / app / from MySQL server command

I want to share a discovery that helped me a lot. This is a MySQL UDF plugin that 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 the Makefile:
  • We will install some compilation tools.
  • sudo apt-get install build-essential
  • sudo apt-get install libmysqlclient15-dev
  • If you cannot install the latest tool from the repository, do sudo apt-get update to update them.
  • Add -fPIC In the gcc command we compile the plugin.
  • Modify the LIBDIR variable to point to the mysqld plugins folder, usually:
  • LIBDIR = / usr / lib / mysql / plugin

  • make

  • ./Install.sh.
  • Already installed but disabled. To turn on:
  • 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 start the MySQL console:

    SELECT sys_eval ("id")

  • if it returns something like:

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

    installation successful

I hope you find this helpful.

Literature:

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

0
linux bash mysql ubuntu
Oct 13 '16 at 15:38
source share

No one has answered this question yet.

See similar questions:

53
Call PHP script from MySQL trigger
2
When a new row is added to the database, you need to call an external command-line program

or similar:

4598
Get the source directory of the Bash script from the script itself
1913
How to check if a program exists from a Bash script?
1762
How to import SQL file using command line in MySQL?
1633
How to parse command line arguments in Bash?
1351
How to set a variable to output a command in Bash?
1324
How do I request Yes / No / Cancel input in a Linux shell script?
1290
How to get list of user accounts using command line in MySQL?
1211
How to exclude a directory in a search. team
1105
How to reset AUTO_INCREMENT in MySQL?
851
Pipe to / from clipboard in Bash script



All Articles