我想这样做:
#Variables
SET @username="jdoe", @password="secret";
# Insert a new MySQL User
CREATE USER @username@'localhost' IDENTIFIED BY @password;GRANT USAGE ON *.* TO @username@'localhost' IDENTIFIED BY @password WITH MAX_QUERIES_PER_HOUR 120 MAX_CONNECTIONS_PER_HOUR 60 MAX_UPDATES_PER_HOUR 60 MAX_USER_CONNECTIONS 2;
但是得到:
#1064 - 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 '@username@'localhost' IDENTIFIED BY @password' at line 2
如何在 CREATE USER 语句中使用变量?