------------------------
-- Mysql Procedure to show all grants
CREATE PROCEDURE `showAllGrants`()
BEGIN
DECLARE done INT DEFAULT 0;END
DECLARE mUser CHAR(16);
DECLARE hostName CHAR(60);
DECLARE cur1 CURSOR FOR SELECT user, host FROM mysql.user;
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;
OPEN cur1;
REPEATCLOSE cur1;
FETCH cur1 INTO mUser, hostName;
IF NOT done THENUNTIL done END REPEAT;
SET @sql := CONCAT('SHOW GRANTS FOR ', QUOTE(mUser), '@', QUOTE(hostName));END IF;
PREPARE grntStmt FROM @sql;
EXECUTE grntStmt;
DROP PREPARE grntStmt;
USAGE:
--------
CALL showAllGrants();
No comments:
Post a Comment