bash脚本中的sql语句“找不到命令”

时间:2016-05-31 13:56:21

标签: mysql bash

我有一个运行一系列sql语句的bash脚本:

#!/bin/bash

mysql -u root -p << QUERY_INPUT

CREATE DATABASE dba_first;
CREATE DATABASE dba_second;
CREATE DATABASE dba_third;

GRANT ALL PRIVILEGES ON `dba%`.* TO `dbuser`@`localhost`;

QUERY_INPUT

当我运行脚本时,我得到:./quick.sh: line 20: dba%: command not found

有什么建议吗?

1 个答案:

答案 0 :(得分:2)

一位好心的人在IRC上回答;必须逃避`

GRANT ALL PRIVILEGES ON \`dba%\`.* TO \`dbuser\`@\`localhost\`;