Ubuntu bash mysql 脚本看起来像这样
mysql -h localhost -u $MYSQLLOGIN -p$MYSQLROOTPASS -t -e '
CREATE USER $USERNAME@'localhost' IDENTIFIED BY $MYSQLPASS;
create database $MYSQLDB;
grant usage on *.* to $USERNAME@localhost identified by $MYSQLPASS;
grant all privileges on $MYSQLDB.* to $USERNAME@localhost';
收到错误信息
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '$MYSQLPASS' at line 1
实际上 $MYSQLPASS 是带有字符串内容的变量。当我测试时,它不是空的。我究竟做错了什么?