通过ssh执行mysql查询

时间:2017-06-12 09:09:05

标签: mysql ssh

我想通过ssh

创建bash别名来运行mysql查询
ssh vagrant@192.168.10.10  "mysql wp-theme -e 'DELETE * FROM wp_options where option_name like \'%_transient%\''";

但问题在于我试图逃离\'%_transient%\'

的部分'

我收到了错误

bash: -c: line 0: unexpected EOF while looking for matching `''
bash: -c: line 1: syntax error: unexpected end of file

1 个答案:

答案 0 :(得分:1)

过了一会儿,我找到了解决方案

ssh vagrant@192.168.10.10  "mysql wp-theme -e 'DELETE FROM \`wp_options\` where \`option_name\` like \"%_transient%\";'"