3

我想将来自fifo管道的数据插入到mysql表中,现在对我来说,这在fifo管道进程被杀死之前是可能的,

命令 :

$>mkfifo /path/to/pipe
$>sudo chmod 666 /path/to/pipe
$>find \ -sl > /path/to/pipe & msql db1 -e"LOAD DATA INFILE '/path/to/pipe' INTO TABLE T1 " &

插入fifo管道中的数据,直到mysql的进程被kill进程关闭。

是否可以在不终止 fifo 管道数据进程的情况下插入数据?

谢谢!!

4

2 回答 2

2

为了澄清@JulienPalard 上面的评论,您应该能够使用以下命令来实现您的目标。

(我使用了两个不同的 shell 进程,而他使用了一个。对于我的描述,尝试让两个 shell 同时可见,以便您可以在一个 shell 中读取输出并在另一个 shell 中写入输入。如果您知道自己在做什么,那么您可以将mysql进程置于后台,从而只使用一个shell。)

外壳 1:输出

$ mkfifo mypipe # create a named pipe
$ chmod 666 mypipe # Give all users read-write access to the pipe
$ tail -f mypipe | mysql -umyName -p mySchema # pipe mypipe into mysql

上面的最后一行告诉命名管道永久地输入 mysql 进程。每当您在 mypipe 中回显某些内容时,它将作为标准输入发送到 mysql 进程。

在此之后,您将不会收到新的提示,因为您的tail命令将一直运行,直到您终止其进程。

当您使用其他shelltail进程(Shell 2:输入)将命令发送到mysql.

外壳 2:输入

$ echo 'show tables;' > mypipe # this will print output onto your *other* shell (Shell 1: output)
$ echo 'insert into mytable (1,2,3);' > mypipe # this performs an insertion
于 2015-05-13T17:56:26.767 回答
0

mysql系统日志有报错吗?我会看看http://www.mysqlperformanceblog.com/2008/07/03/how-to-load-large-files-safely-into-innodb-with-load-data-infile/

于 2011-02-01T10:01:43.340 回答