如何从多个帐户触发 MySQL 触发器

发布于 2024-09-29 07:46:35 字数 342 浏览 2 评论 0原文

这是我的情况:我有一个 MySQL 数据库,我想在其中使用触发器来自动管理一些表中的日期创建和日期修改字段的更新。后来,我想将它们扩展到记录数据更改,但目前不存在。

触发器工作正常并按预期更新字段。问题是应用程序帐户现在基本上是唯一可以影响这些表的帐户,其他 MySQL 用户帐户(例如我的)的操作会失败,因为定义者是应用程序帐户。

无论谁在桌子上执行命令,我似乎都找不到一种方法来触发触发器,这非常令人沮丧。有没有办法无论用户如何都打开触发器来触发或允许多个用户触发触发器?

我们目前运行的是 MySQL 5.0.18 - 改变这一点的可能性很小,因为这里负责基础设施的人们相当抵制修复(至少在他们看来)没有损坏的东西。

Here's my situation: I have a MySQL database in which I'd like to use triggers to automatically manage the updating of date creation and date modified fields in a few of my tables. Later, I'd like to expand them into logging data changes, but that's neither here nor there at the moment.

The triggers work fine and update the fields as intended. The problem is that the application account is now basically the only account that can affect these tables, actions from other MySQL user accounts (such as mine) fail because the definer is the application account.

I can't seem to find a way to have the trigger fire regardless of who executes a command on the tables and it's quite frustrating. Is there a way to either open up a trigger to fire regardless of user or allow multiple users to fire the trigger?

We're currently running MySQL 5.0.18 - changing this is very unlikely as the folks here in charge of infrastructure are rather resistant to fixing what (in their minds at least) isn't broken.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文