MySQL Trigger Error#2013 - 查询期间与MySQL服务器的连接丢失

时间:2013-07-18 20:50:51

标签: c++ mysql triggers

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

这是我的触发器代码:

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.

1 个答案:

答案 0 :(得分:1)

更改

SET cmd=CONCAT('/home/lab/Dropbox/simulator/version_unified/./simulator');

SET cmd=CONCAT('/home/lab/Dropbox/simulator/version_unified/simulator');
当文件在当前工作目录中时,使用

./。