需要通过linux批量动态执行mysql sql语句,借助于EOF传参,发现传入`反瞥号会被识别,\\斜杠也会被识别,这时候需要转移,当然不能一个一个去转义,直接用双引号引上EOF就对接下来的整个输入转义了。
如下:
mysql -uroot -p123456 -h192.168.6.111 <<"EOF" use test; select * into outfile '$outfile' FIELDS ESCAPED BY '\\' TERMINATED BY '|' ENCLOSED BY '"' LINES TERMINATED BY '\r\n' from $1; EOF
转载于:https://blog.51cto.com/imysqldba/1352414