提前感谢您帮忙!!!
我有一个在本地工作的mySQL语句:
mysql -u root -ppassword -e 'SELECT "Column 1 text" as "Column 1 Heading", table1.* FROM table1;' dataBase1
如果我尝试使用SSH运行它,则会出错。我不知道如何通过SSH获取SQL语句中的引用。
ssh server1 "mysql -u userName -ppassword -e 'SELECT 'Column 1 text' as 'Column 1 Heading', table1.* FROM table1;' dataBase1"
任何建议都将非常感谢..
谢谢, 〜Donavon
答案 0 :(得分:0)
尝试
ssh server1“mysql -u userName -ppassword dataBase1 -e'SELECT \”Column 1 text \“as \”Column 1 Heading \“,table1。* FROM table1;' “
答案 1 :(得分:0)
在结合几个来源的反馈之后,这就是我想出来的。
使用echo将select语句移动到命令的前面并将其传递给ssh mysql命令,我不需要担心转义。
似乎有效:
echo 'SELECT "server1" as "Server", table1.* FROM table1 INTO OUTFILE "/tmp/temp.csv" FIELDS ESCAPED BY """" TERMINATED BY "," ENCLOSED BY """" LINES TERMINATED BY "\r\n"' | ssh server1 mysql -u root -ppassword dataBase