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 ;
4

1 回答 1

1

确认您使用的是正确的插件文件夹:

SHOW VARIABLES LIKE 'plugin_dir';

重新创建函数:

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

确保您使用的是可执行文件的完整路径:

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

并确保MySQL 运行的任何用户都有权访问此脚本,并执行它正在执行的任何操作。

于 2015-12-15T20:32:12.547 回答