I'm new to MySQL. I was trying to create a procedure with two parameters:
- user_name
- password
...that will be generated and granted full rights:
DELIMITER $$
DROP PROCEDURE IF EXISTS `gen_user`$$
CREATE PROCEDURE `gen_user`(`user_name` VARCHAR(10), `keyword` VARCHAR(255))
BEGIN
CREATE USER `user_name`@'localhost' IDENTIFIED BY `keyword`
GRANT ALL PRIVILEGES ON * . * TO `user_name`@'localhost'
FLUSH PRIVILEGES
END$$
DELIMITER ;
The error I get is:
Error Code: 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 '`keyword` GRANT ALL PRIVILEGES ON * . * TO `user_name`@'localhost' FLUSH P' at line 3