A stored procedure to show all grants in the database.
USE mysql; DELIMITER // CREATE PROCEDURE showAllGrants() BEGIN DECLARE done INT DEFAULT 0; DECLARE theUser CHAR(16); DECLARE theHost CHAR(60); DECLARE cur1 CURSOR FOR SELECT user, host FROM mysql.user; DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1; OPEN cur1; REPEAT FETCH cur1 INTO theUser, theHost; IF NOT done THEN SET @sql := CONCAT('SHOW GRANTS FOR ', QUOTE(theUser), '@', QUOTE(theHost)); PREPARE grantStatement FROM @sql; EXECUTE grantStatement; DROP PREPARE grantStatement; END IF; UNTIL done END REPEAT; CLOSE cur1; END// DELIMITER ; CALL showAllGrants();
PlanetMySQL Voting: Vote UP / Vote DOWN