Tôi muốn làm điều này:MySQL TẠO NGƯỜI DÙNG với biến?
#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;
Nhưng nhận được:
#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
Làm thế nào để sử dụng một biến trong câu lệnh CREATE USER?
thể trùng lặp của [lỗi cú pháp từ CREATE USER với các biến cho tên truy cập và mật khẩu] (http://stackoverflow.com/questions/11368966/syntax-error-from -create-user-with-variables-giving-username-and-password) – aleroot
@aleroot Tôi không chắc đó là vấn đề tương tự vì nó liên quan đến việc tạo một thủ tục lưu sẵn. – Nick