In a MySQL script I would like to do something like this:
SET @username = CONCAT(DATABASE(), "-1@`%`");
CREATE USER @username;
but I can’t resolve the syntax error in the CREATE USER line.
Is there a way to escape the inline variable so that CREATE USER can have a dynamically created user?
You can do it with prepared statements: