我正在尝试在我的 shell 脚本中执行一个 mysql 查询,该脚本没有执行。这是我想要做的
query="\"select count(*) from information_schema.tables where TABLE_SCHEMA not in ('mysql','performance_schema','information_schema') and engine!='INNODB';\""
回声$查询
"select count(*) from information_schema.tables where TABLE_SCHEMA not in ('mysql','performance_schema','information_schema') and engine!='INNODB';"
在我的 shell 脚本中,我在下面执行,它不起作用。它没有给出任何错误,只是没有考虑 -e 选项并列出了 mysql 客户端的所有有效选项。
mysql -u$username -p$password -e$query
我什至在我的 shell 提示符下验证了
echo "mysql -uroot -p -e$query"
mysql -uroot -p -e"select count(*) from information_schema.tables where TABLE_SCHEMA not in ('mysql','performance_schema','information_schema') and engine!='INNODB';"
这非常好,可以毫无问题地执行。我不知道现在该怎么办。请帮忙。谢谢
你需要这样做:
或者
双引号不需要是
query
变量的一部分