我想做到這一點: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