2

I am using phpmyadmin. I am using a trigger in mysql which calls a php script after inserting something in a table. My trigger contains this.

DECLARE result INT;
SET result=(select sys_exec('C:/xampp/php/php.exe C:/xampp/htdocs/mysite/hello.php'));

But i got this error while trying to insert something to the table.

#1305 FUNCTION db.sys_exec does not exists

(my database name is db) Help me with this.Thanks.

2
  • Did you create such a function? Commented Jun 26, 2014 at 15:03
  • I don't think it's a built-in function and so the error. Commented Jun 26, 2014 at 15:05

3 Answers 3

1

sys_exec is not a standard mysql function. It's provided by an external UDF plugin, and must be installed separately: https://github.com/mysqludf/lib_mysqludf_sys#readme

Sign up to request clarification or add additional context in comments.

7 Comments

thanks.. did i need to install lib_mysqludf_sys.sql or any other extension?
You've got to install the binary lib_mysqludf_sys.so first. Maybe you've got to compile this binary for your platform to get this up and running.
@user3496195 And please read the note of caution in the documentation github.com/mysqludf/lib_mysqludf_sys/blob/master/…
@VMai please provide me some page which has complete installation procedure
@user3496195: A bit more readable: htmlpreview.github.io/?https://github.com/mysqludf/… and have a look at the MySQL manual chapter dev.mysql.com/doc/refman/5.6/en/adding-functions.html
|
0

In Linux Ubuntu system and few other distributions, mysql server package contains apparmor which limits UDF functions.

Stop apparmor

sudo service apparmor stop

Check apparmor status

sudo service apparmor status

Even then if you get the same error, restart mysql service

Restart mysql

sudo service mysql restart

Comments

0
  1. Git clone the files on machine having MySQL deployed

    git clone https://github.com/mysqludf/lib_mysqludf_sys

  2. Execute below command in the directory where the above repo is checked out :

gcc -DMYSQL_DYNAMIC_PLUGIN -fPIC -Wall -m64 -I/usr/include/mysql -I. -shared lib_mysqludf_sys.c -o lib_mysqludf_sys.so

  1. Copy the file lib_mysqludf_sys.so to /usr/lib/mysql/plugin/ The location /usr/lib/mysql/plugin/ is one to be verified by running below command in mysql shell

    SHOW VARIABLES where variable_name = 'plugin_dir';

  2. Now finally create the function in my sql shell;

    CREATE FUNCTION sys_exec RETURNS INT SONAME 'lib_mysqludf_sys.so';

  3. Verify that the function is created, using below command in mysql shell. This command shall return rows with one containing sys_exec as well:

    select * from mysql.func;

Comments

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.