无法在 5.1.32 上创建具有 TRIGGER 权限的 MySQL 触发器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1627383/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 14:21:26  来源:igfitidea点击:

Can't create MySQL trigger with TRIGGER privilege on 5.1.32

sqlmysqltriggersmysql-management

提问by Michael Moussa

My fellow developers and I have our own development schemas on a shared MySQL development database. My assignment requires me to create triggers in my schema, yet I've been unsuccessful so far.

我的开发人员和我在共享的 MySQL 开发数据库上拥有自己的开发模式。我的任务要求我在我的模式中创建触发器,但到目前为止我没有成功。

CREATE TRIGGER myTrigger AFTER DELETE on myTable
FOR EACH ROW BEGIN
    -- DO STUFF
END;

MySQL says: ERROR 1419 (HY000): You do not have the SUPER privilege and binary logging is enabled (you mightwant to use the less safe log_bin_trust_function_creators variable)

MySQL 说:ERROR 1419 (HY000):您没有 SUPER 权限并且启用了二进制日志记录(您可能想要使用不太安全的 log_bin_trust_function_creators 变量)

I checked the MySQL manual (http://dev.mysql.com/doc/refman/5.1/en/privileges-provided.html):

我检查了 MySQL 手册(http://dev.mysql.com/doc/refman/5.1/en/privileges-provided.html):

The TRIGGER privilege enables you to create and drop triggers. You must have this privilege for a table to create or drop triggers for that table. This privilege was added in MySQL 5.1.6. (Prior to MySQL 5.1.6, trigger operations required the SUPER privilege.)

TRIGGER 权限使您能够创建和删除触发器。您必须具有该表的此权限才能为该表创建或删除触发器。这个权限是在 MySQL 5.1.6 中添加的。(在 MySQL 5.1.6 之前,触发器操作需要 SUPER 权限。)

We are running "5.1.32-enterprise-gpl-advanced-log", so the TRIGGER privilege should be sufficient; however, the DBA granted me the TRIGGER privilege on mySchema.* and I can see it when I do SHOW GRANTS;, yet I still get this error about needing the "SUPER" privilege. We don't want to give all of the developers SUPER.

我们运行的是“5.1.32-enterprise-gpl-advanced-log”,所以TRIGGER权限应该足够了;然而,DBA 授予我mySchema.*的 TRIGGER 特权,当我执行 SHOW GRANTS; 时我可以看到它;但我仍然收到关于需要“SUPER”特权的错误。我们不想给所有的开发人员超级。

Any suggestions?

有什么建议?

回答by nathan

Here is the bug report for this. One option is to run with the --log-bin-trust-function-creators option turned on, which will allow you to create triggers without the SUPER privilege. This pageexplains what turning that option on means. Basically it has to do with whether or not MySQL thinks your triggers are deterministic (i.e. safe for replication). Your DBA may or may not be comfortable running in that mode. It's not ideal, but better than giving out SUPER...

这是这个的错误报告。一种选择是在打开 --log-bin-trust-function-creators 选项的情况下运行,这将允许您在没有 SUPER 权限的情况下创建触发器。 此页面解释了打开该选项的含义。基本上它与 MySQL 是否认为您的触发器是确定性的(即复制安全)有关。您的 DBA 可能适合也可能不适合在该模式下运行。这并不理想,但总比给 SUPER 好...

UPDATE: The docs at the second link actually make it sound like you may be able to get around this by using row-based replication, or even mixed-mode replication. At least that would make it safe for replication. Whether or not you would still be required to have SUPER, I don't know, but it may be worth a try.

更新:第二个链接中的文档实际上听起来您可以通过使用基于行的复制甚至混合模式复制来解决这个问题。至少这将使复制安全。我不知道您是否仍然需要拥有 SUPER,但它可能值得一试。