我想做到这一点:MySQL使用变量创建用户?
#Variables
SET @username="jdoe", @password="secret";
# Insert a new MySQL User
CREATE USER @[email protected]'localhost' IDENTIFIED BY @password;GRANT USAGE ON *.* TO @[email protected]'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 '@[email protected]'localhost' IDENTIFIED BY @password' at line 2
如何在CREATE USER语句中使用一个变量?
可能重复http://stackoverflow.com/questions/11368966/syntax-error-from -create-user-with-variables-giving-username-and-password) – aleroot 2012-08-14 12:12:46
@aleroot我不确定这是相同的问题,因为它涉及到创建存储过程。 – Nick 2012-08-14 12:19:39