MySQL Forums
Forum List  »  Spanish

Procedimiento almacenado para crear usuarios
Posted by: Geronimo Fernandez
Date: November 15, 2014 01:22PM

Estoy intentando crear un Procedimiento Almacenado para crear usuarios en MySQL Server 5.6.21, pero me lanza el siguiente error:

Error Code: 1445. Not allowed to set autocommit from a stored function or trigger.

El codigo a continuacion:


CREATE PROCEDURE `add_User`(IN p_Name VARCHAR(45), IN p_Passw VARCHAR(200))
BEGIN

DECLARE flag_exist TINYINT(1) DEFAULT 0;

SELECT COUNT(*)
INTO flag_exist
FROM
`mysql`.`USER`
WHERE
`mysql`.`USER`.`User` = p_Name;

IF flag_exist = 0 THEN
CREATE USER p_Name;
GRANT ALL PRIVILEGES ON *.* TO p_Name;
SET PASSWORD FOR p_Name = PASSWORD (p_Passw);
FLUSH PRIVILEGES;

/* NO FOUNT
INSERT INTO user VALUES
('localhost',p_Name,PASSWORD(p_Passw),'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');
*/
END IF;

END

Options: ReplyQuote


Subject
Views
Written By
Posted
Procedimiento almacenado para crear usuarios
3046
November 15, 2014 01:22PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.