M
M
malan2013-08-27 09:26:42
MySQL
malan, 2013-08-27 09:26:42

Setting user permissions with a dynamic query?

I create a dynamic query in a stored procedure to create a user. The creation of the user itself goes fine, but when you try to set the rights for him, an error pops up:

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 'GRANT USAGE ON *.* TO 'malan1'@'localhost'' at line 2

set @new_user_create=CONCAT(
'CREATE USER ''malan1''@''localhost'';
GRANT USAGE ON *.* TO ''malan1''@''localhost'';');
PREPARE cu FROM @new_user_create;
EXECUTE cu;

I don't understand what he's complaining about.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question