[英]MySQL Trigger Error #2013 - Lost connection to MySQL server during query
我想創建一個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.
更改
SET cmd=CONCAT('/home/lab/Dropbox/simulator/version_unified/./simulator');
至
SET cmd=CONCAT('/home/lab/Dropbox/simulator/version_unified/simulator');
當文件位於當前工作目錄中時,將使用./。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.