在MySQL中,是否可以设置存储过程以无限制地使用精选表?
我有一系列复杂的连接和工会的选择,我经常使用这些选择,这些选择是在存储过程中的。我想要一个更安全的用户设置,该设置只能在这些存储过程中调用这些选择的语句。似乎仅执行权限就不允许我执行包含某些语句的存储过程,但是似乎我不能在存储过程中授予某些权限,而无需将其授予整个表/表。有没有办法在MySQL中完成此操作,在SQL Server中似乎有可能,但是我在MySQL中找不到任何东西。我想授予完整的许可,以在我的存储过程中执行所有操作,但只有在通过我的存储过程进行调用时。
I have a series of complicated SELECTS with JOINS and UNIONS which I use frequently that I have placed in stored procedures. I wanted a more secure user set up that could only call these SELECT statements within these stored procedures. It seem the EXECUTE permission alone does not allow me to execute stored procedures which contain SELECT statements, but it also seems that I cannot grant SELECT permissions within the stored procedures without granting them for the whole table/tables. Is there a way to accomplish this in MYSQL, it appears it is possible in SQL Server, but I can't find anything on it in MYSQL. I want to grant full permission to execute everything within my stored procedures, but only when called through my stored procedures.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Grant
仅在表上选择
仅贴上特殊用户名的权限。然后使该用户成为过程的定义器,然后在创建过程
语句中使用SQL Security Deparer
选项。给予普通用户
执行
在过程中的权限(请参阅 https://dba.stackexchange.com/questions/97719/how-to-to-to-grant-execute-on-mysql )。使用这些过程设置,当过程正在运行时,它具有基于定义器的权限,允许其访问用户无法直接访问的表。
Grant
SELECT
permission on the tables only to a special username. Then make that user the definer of the procedure and use theSQL SECURITY DEFINER
option in theCREATE PROCEDURE
statement.Give the ordinary users
EXECUTE
permission on the procedures (see https://dba.stackexchange.com/questions/97719/how-to-grant-execute-on-mysql).With these procedure settings, when the procedure is running it has permissions based on the definer, allowing it to access tables that the user can't access directly.
授予在过程中执行mydb.myproc to'someuser'@'someHost';
GRANT EXECUTE ON PROCEDURE mydb.myproc TO 'someuser'@'somehost';