SET @user = '[email protected]';
SET @pass = 'bar';
SET @sql = 'CREATE USER ? IDENTIFIED BY ?';
PREPARE stmt FROM $sql;
,我得到錯誤
ERROR 1064 (42000): 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 '? IDENTIFIED BY ?'
我也嘗試過多種變體如何定義變量,但還是沒有任何的運氣。
SET @user = "'foo'@'localhost'";
SET @sql = 'CREATE USER ? IDENTIFIED BY ?';
甚至
SET @user = 'foo';
SET @host = 'localhost';
SET @sql = 'CREATE USER [email protected]? IDENTIFIED BY ?';
相當類似的問題已經被問2年多前,但仍然沒有有用的答案:( Create User with MySQLi Prepared Statement
開始得到支持? –
@ElliottFrisch在這種情況下,只需從控制檯輸入MySQL,但如果需要,我也可以使用PHP。 – DarkSide