简体   繁体   English

如何将特定存储过程的执行授予用户

[英]How to grant execute on specific stored procedure to user

I have created some stored procedure on a specific schema. 我已经在特定架构上创建了一些存储过程。

In this stored procedure, I want to grant execute privilege. 在此存储过程中,我想授予执行权限。

So I wrote that : 所以我写道:

GRANT EXECUTE ON PROCEDURE schema_name.proc_name TO 'user_name';
GRANT SELECT ON mysql.proc to 'user_name';

The problem is : My user can see every stored procedure. 问题是:我的用户可以看到每个存储过程。 I wish he could only see the procedure where he has the EXECUTE privilege. 我希望他只能看到他拥有EXECUTE特权的程序。

Is there a way to achieve that ? 有没有办法实现这一目标?

Thanks in advance. 提前致谢。

Yes... this works as expected if you don't grant the user the SELECT privilege on the mysql.proc table, either directly or indirectly, such as with GRANT SELECT ON *.* TO ... 是的...如果你没有直接或间接地授予用户mysql.proc表的SELECT权限,例如使用GRANT SELECT ON *.* TO ... ,这将按预期工作GRANT SELECT ON *.* TO ...

Without SELECT permission on this table, a user can only see the existence of stored procedures and stored functions where they have other permissions, like EXECUTE . 如果没有此表的SELECT权限,用户只能看到存储过程和存储函数的存在,它们具有其他权限,如EXECUTE

Under the hood, the lack of SELECT on mysql.proc also prevents the user from seeing the procedures they don't have access to via the information_schema.routines pseudo-table. 在引擎盖下, mysql.proc上缺少SELECT也会阻止用户通过information_schema.routines伪表查看他们无法访问的过程。

You shouldn't need to GRANT SELECT ON mysql.proc to enable the user to execute procedures or functions... and if you do, then that seems like the question. 您不需要在GRANT SELECT ON mysql.proc上进行GRANT SELECT ON mysql.proc以使用户能够执行程序或函数......如果这样做,那么似乎就是问题所在。

Problem solved. 问题解决了。

In fact, To be able to execute stored procedure within MySQLForExcel, we need to SET the DEFINER of each stored procedure that we want to be called by a MySQLForExcel user. 实际上,为了能够在MySQLForExcel中执行存储过程,我们需要设置我们想要由MySQLForExcel用户调用的每个存储过程的DEFINER。

DELIMITER $$

DROP PROCEDURE IF EXISTS `procedure_name` $$
CREATE DEFINER=`user_mysqlforexcel` PROCEDURE `procedure_name`(param)
BEGIN
     Do smth as usual
END $$

I found that here 我在这里找到了

Thank for the help. 谢谢你的帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM