2

我想创建一个 MySQL 触发器,当将行插入 MySQL 表时,我在其中执行 C++ 程序。为此,我使用了 LIB_MYSQLUDF_SYS,它已成功安装为 UDF。我的代码基于教程。

这是我的触发代码:

DELIMITER @@
CREATE TRIGGER startSimulator 
BEFORE INSERT ON `trigger`
FOR EACH ROW 
BEGIN
 DECLARE cmd CHAR(255);
 DECLARE result int(10);
 SET cmd=CONCAT('/home/lab/Dropbox/simulator/version_unified/./simulator');
 SET result = sys_exec(cmd);
END;
@@
DELIMITER ;

如果不清楚,系统程序使用./simulator. 但是,当我使用INSERT INTO trigger (trigger) VALUES (yes)在“触发器”表中插入一行时,出现以下错误:

#2013 - Lost connection to MySQL server during query

当我删除触发器时,查询执行得很好。有没有人知道为什么会发生这种情况?

mysqld --log-warnings=2产量:

130719 15:53:59 [Note] Plugin 'FEDERATED' is disabled.
mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)
130719 15:53:59 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
130719 15:53:59 InnoDB: The InnoDB memory heap is disabled
130719 15:53:59 InnoDB: Mutexes and rw_locks use GCC atomic builtins
130719 15:53:59 InnoDB: Compressed tables use zlib 1.2.3.4
130719 15:53:59 InnoDB: Initializing buffer pool, size = 128.0M
130719 15:53:59 InnoDB: Completed initialization of buffer pool
130719 15:53:59  InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'open'.
InnoDB: Cannot continue operation.
4

0 回答 0