我觉得MySQL手册中定义器的解释很难理解,所以我不确定运行应用程序的“execute user”需要什么特权。为了安全起见,我喜欢将“execute user”限制在所需的最小权限范围内。
我知道触发器/存储过程的创建者需要超级权限,但是“执行用户”也需要超级权限吗?
我在一个用户下创建了一个触发器,最终失去了数据库的特权。“execute user”没有超级权限,触发器失败的MySQL更新失败。
我给了'execute user‘超级特权,并通过删除和创建触发器将定义器更改为root,这一切都能工作。我必须给‘执行用户’超级特权,还是我必须确保定义用户仍然存在,并拥有超级特权?
MySQL的触发器和存储过程用于用户管理的最佳实践是什么?
发布于 2013-11-06 21:24:29
在存储例程和触发器之间有一些区别。在这里,我将试图帮助解决触发的问题。
我希望下面的总结是有帮助的。
第一件事是确定您正在使用的MySQL版本。
根据文件:
MySQL 5.0:13.1.11.创建触发器语法
从MySQL 5.0.17开始,MySQL在检查触发器特权时会考虑定义者用户,如下所示:
- The SUPER privilege.
- The SELECT privilege for the subject table if references to table columns occur using OLD.col\_name or NEW.col\_name in the trigger body.
- The UPDATE privilege for the subject table if table columns are targets of SET NEW.col\_name = value assignments in the trigger body.
- Whatever other privileges normally are required for the statements executed by the trigger.
在MySQL 5.0.17之前,定义器不可用,MySQL检查触发器特权如下:
MySQL 5.1及以上版本:13.1.19。创建触发器语法
MySQL在检查触发器特权时将定义用户考虑在内,如下所示:
- The TRIGGER privilege. (SUPER prior to MySQL 5.1.6.)
- The SELECT privilege for the subject table if references to table columns occur using OLD.col\_name or NEW.col\_name in the trigger body.
- The UPDATE privilege for the subject table if table columns are targets of SET NEW.col\_name = value assignments in the trigger body.
- Whatever other privileges normally are required for the statements executed by the trigger.
https://stackoverflow.com/questions/19815837
复制相似问题