title: How to execute external script/app/command from MySQL Server
body: <p>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.</p>
  
  <ul>
  <li>Download from : <a href="https://github.com/mysqludf/lib_mysqludf_sys/archive/master.zip" rel="nofollow noreferrer">https://github.com/mysqludf/lib_mysqludf_sys/archive/master.zip</a></li>
  <li>Open the folder and edit Makefile:</li>
  <li>We will install some compilation tools</li>
  <li><code>sudo apt-get install build-essential</code></li>
  <li><code>sudo apt-get install libmysqlclient15-dev</code></li>
  <li>If you can not install the latest tool from the repository, do <code>sudo apt-get update</code> to update them.</li>
  <li>Add <code>-fPIC</code> In the command gcc to compile the plugin us.</li>
  <li>Modify <em>LIBDIR</em> variable to point to your mysqld plugins folder, usually:</li>
  <li><p><code>LIBDIR = / usr / lib / mysql / plugin</code></p></li>
  <li><p><code>make</code></p></li>
  <li><code>./Install.sh.</code></li>
  <li>Already installed but disabled. To enable:</li>
  <li><code>sudo Ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/</code></li>
  <li><code>sudo Apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld</code></li>
  <li><p>to verify the installation, you can run from the MySQL console:</p>
  
  <blockquote>
    <p>SELECT sys_eval ("id")</p>
  </blockquote></li>
  <li><p>if it returns something like:</p>
  
  <blockquote>
    <p>uid = 122 (mysql) gid = 130 (mysql) groups = 130 (mysql)</p>
  </blockquote>
  
  <p>the installation is <em>successful</em></p></li>
  </ul>
  
  <p>I hope you find it useful.</p>
  
  <p>References:</p>
  
  <p><a href="http://dev.mysql.com/doc/refman/5.7/en/faqs-triggers.html#qandaitem-23-5-1-11" rel="nofollow noreferrer">http://dev.mysql.com/doc/refman/5.7/en/faqs-triggers.html#qandaitem-23-5-1-11</a></p>
  
  <p><a href="http://jawtech.com/drupal7/?q=content/how-create-mysql-triggers-execute-external-scriptphp-ubuntu-server-14" rel="nofollow noreferrer">http://jawtech.com/drupal7/?q=content/how-create-mysql-triggers-execute-external-scriptphp-ubuntu-server-14</a></p>