4

I am currently trying to use a mysql trigger to launch a php script. When launched the script retrieves data from a particular website, and puts it into another table. I have tested the script, and it currently works when I run it using php5. I also have properly installed lib_mysqludf_sys, and moved the proper folders into the plugin folder for mysql. When I created the trigger I received no errors. It just wont run my php script. Where did I go wrong, and how could I fix it?

DELIMITER $$
CREATE TRIGGER getFriends
    -> AFTER INSERT ON tbluser
    -> FOR EACH ROW    
    -> BEGIN
    ->   DECLARE RESULT INT;
    ->   SET RESULT = sys_exec('php5 /var/www/html/getFriends.php');
    ->END$$;
DELIMITER ;

1 Answer 1

1

Confirm you're using the right plugin folder:

SHOW VARIABLES LIKE 'plugin_dir';

Recreate the function:

DROP FUNCTION IF EXISTS sys_exec;
CREATE FUNCTION sys_exec RETURNS int SONAME 'lib_mysqludf_sys.so';

Ensure you're using the full path to your executable:

SET RESULT = sys_exec('/usr/bin/php5 /var/www/html/getFriends.php');

And make sure that whatever user MySQL is running as has the permissions to access this script, and do whatever it's doing.

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

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.