2013-07-18 51 views
1

我想創建一個MySQL觸發器,當一行插入到MySQL表中時,我執行一個C++程序。爲此,我使用LIB_MYSQLUDF_SYS,我成功將其安裝爲UDF。我的代碼基於this教程。MySQL觸發錯誤#2013 - 在查詢過程中丟失與MySQL服務器的連接

這裏是我的觸發代碼:

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. 
+0

什麼是操作系統?該操作系統中是否有防火牆? –

回答

1

變化

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

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

./當該文件在當前工作目錄使用。

+0

試過這個,但我仍然得到相同的錯誤。 – Charles

+0

嘗試執行/家庭/實驗室/ Dropbox的/模擬器/ version_unified /模擬器 如果這不起作用,你可以發佈更詳細的日誌?使用--log-warnings = 2 –

+0

運行mysqld它仍然無效。我運行了'mysqld --log-warnings = 2',並將結果發佈到我更新的OP中。 – Charles

相關問題