0

The output of this echo is not passed on to the next command using pipe.

echo 'set foreign_key_checks = 0; truncate table saurabh.bus_services;' |
mysqldump --compact --no-create-info -h192.168.950.180 -uroot -p live pnlbus |
more

I want the set and truncate commands followed by the dump output.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
shantanuo
  • 31,689
  • 78
  • 245
  • 403

3 Answers3

3
(echo 'set foreign_key_checks = 0; truncate table saurabh.bus_services;' ; mysqldump --compact --no-create-info -h192.168.150.80 -uroot -p live pnlbus) | more
liori
  • 40,917
  • 13
  • 78
  • 105
0

Right now you are sending set foreign_key_checks = 0; truncate table saurabh.bus_services; to the mysqldump command. I guess this is not what you mean to do.

Try something like

echo 'set foreign_key_checks = 0; truncate table saurabh.bus_services;' > output.tmp
mysqldump --compact --no-create-info -h192.168.150.80 -uroot -p live pnlbus >> output.tmp
more output.tmp
gnud
  • 77,584
  • 5
  • 64
  • 78
0

Does the 'mysqldump' command execute arbitrary SQL as well as dump the data?

I suspect not, in which case, you need to echo the the 'set' and 'truncate' commands to 'mysql' rather than mysqldump.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278