在其他RDBMS中,可以将查看某个存储过程(PROCEDURE)定义的权限给某个用户,例如在SQL Server中,可以单独将查看ProcedureName定义的权限授予UserA
GRANTVIEWDEFINITIONONProcedureNameTOUserA; --用具体的存储过程名和账号替换
那么在MySQL中能否实现这个功能呢? 找了很多资料,没有看到有这方面的功能,官方文档没有涉及这样的权限,网上有个方法:可以通过授予用户查询mysql.proc这样的权限来间接实现这个功能
grant select on mysql.proc tousrname@'xxx.xxx.xxx.xxx';
个人简单测试了一下,这样授权后,发现还是有一些其他问题。
mysql> show create procedure prc_insert; --没有授权前报这个错误。ERROR 1305 (42000): PROCEDURE prc_insert does not existmysql> show create procedure prc_insert\G; --授权后*************************** 1. row ***************************Procedure: prc_insertsql_mode: STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTIONCreate Procedure: CREATE DEFINER=`root`@`localhost` PROCEDURE `prc_insert`(in cnt int)begindeclare i int;set i=1;while i < cnt doinsert into test(id, name) select i, C