Insert data into mysql table data from FIFO channel in linux continuously

I want to insert data from a fifo pipe into a mysql table, right now for me, this is possible until the fifo pipe process is killed,

team:

$>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 " &

data in the fifo channel is inserted until the mysql process is completed by the kill process.

Is it possible to insert data without killing the fifo pipe data process in?

Thank!!

+3
source share
2 answers

To clarify @JulienPalard's comment above, you can achieve your goal with the following commands.

( , . , . , 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 , .

tail (Shell 2: input) mysql.

Shell 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
+1

Source: https://habr.com/ru/post/1786788/


All Articles