Open Source Technology
This Blog consist of internet technologies focusing on web world i.e web technologies.
Thursday, January 5, 2012
Friday, October 14, 2011
Mysql: show all grants
MYSQL PROCEDURE:
------------------------
-- Mysql Procedure to show all grants
CREATE PROCEDURE `showAllGrants`()
BEGIN
USAGE:
--------
CALL showAllGrants();
------------------------
-- 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();
Subscribe to:
Posts (Atom)