Monday, 15 February 2010

mysql - Allow GRANT in procedures? -


I have created a process that will create a statement to allow the user with a password. I have created this process to avoid granting explicit grant permission to admin users, instead let them use the processes that I do properly. The process is as follows:

  CREATE PROCEDURE Approval (perm VARCHAR (30), Target VARCHAR (30), ID VARCHAR (8), Host VARCHAR (45) Passwd VARCHAR (45) SET @setPermissionCmd = CONCAT ('grant'), trans, 'o', target, 'to', id, '' '', hosted by '' '' '' ', Pasvadi, '' '; '); Set display @setPermissionCmd from STMT; EXECUTE set display STMt; Set DEALLOCATE PERMissionStmt; Flush Pvt .; END  

When I call In this process, I get an error code 1142 that I do not have permission for GRANT here There are two problems. One, I am executing it as the root in which all permissions should be (I have not taken it anyway, and root has created that process) . Two, when permitted to execute the process, it should be allowed to allow whatever is done inside it.

My exam:

 < Code> $ mysql -u root -p enter password: MySQL Monitor ends with the welcome order; Or your MySQL connection ID1 server version: 5.5.35-1ubuntu1 (Ubuntu) Copyright (C) 2000, 2013, Oracle and / or its affiliates All Rights Reserved. Oracle is a registered trademark of Oracle Corporation and / or its affiliates names may be trademarks of their respective owners. Type 'help;' Or '\ c' to clear the current input statement for help, type '\ c' mysql & gt; Use the exam; MySQL and gt; Create Table 'Table Test' (Unassigned `ID` INT); The query is ok, affecting 0 rows (0.00 seconds) mysql & gt; Identify user 'user test' @ 'localhost' as 'mapped'; The query is ok, affecting 0 rows (0.00 seconds) mysql & gt; Show user grants for 'user test' @ 'localhost'; + ------------------------------------------------- -------------------------------------------------- -------------- + | UserTest @ localhost for grants | + ------------------------------------------------- -------------------------------------------------- -------------- + | Grant on password '* 6C8989366EAF 7797696 AD 8AA 7A 7 FC1176A9 CEF4' * * 'User Test' @ 'Localhost'. + ------------------------------------------------- -------------------------------------------------- -------------- + 1 set in row (0.00 seconds) mysql & gt; DELIMITER // mysql & gt; If the repatriated accreditation `// query is ok, then affecting 0 rows, 1 warning (0.00 seconds) mysql & gt; `Receipts '(30), - & gt;` Target' VARCHAR (30), - & gt; `ID` VARCHAR (8), - & gt;` Host 'VARCHAR (45), - & gt; `Password` VARCHAR (45)) - & gt; BEGIN - & gt; SET @ `setPermissionCmd` = CONCAT (- & gt; 'Grant', 'Permit', 'On',` Target`, ``> TO '' ', `id`,' '' @ '' ', `Host ',' '' & gt; identified as '' ',' passwd`, '' ';'); - & gt; Prepare `set PERMissionCmd` from @ setPermissionStmt`; - & gt; EXECUTE`Setting Stmt`; - & gt; Prepare DEALLOCATE 'Presentation Stmt`; - & gt; Flush Pvt .; - & gt; END // query is OK, affect 0 rows (0.00 seconds) mysql & gt; DELIMITER; Mysql & gt; Call 'Revert' ('Select', 'Tablet', 'User Test', 'Localhost', 'Mypass'); The query is ok, affecting 0 rows (0.00 seconds) mysql & gt; Show user grants for 'user test' @ 'localhost'; + ------------------------------------------------- -------------------------------------------------- -------------- + | UserTest @ localhost for grants | + ------------------------------------------------- -------------------------------------------------- -------------- + | Grant on password '* 6C898 9 366 EAFAF 75 Bb 670 ADA 7A 7 FC 1176 A9 CEF 4' * User 'Test' @ 'Localhost'. | Select 'test'. 'User' test from 'tableTest`' @ 'localhost' | + ------------------------------------------------- -------------------------------------------------- -------------- + 2 lines set (0.00 seconds)  

No comments:

Post a Comment