我应该如何审核 MySQL 表中的更改(使用 MySQL 4)?

发布于 2024-07-07 08:32:12 字数 213 浏览 7 评论 0原文

我被要求审核 MySQL 表中的任何/所有更改。 有谁知道有什么工具可以帮助我做到这一点,还是我需要编写自己的解决方案?

如果我编写自己的审计,我最初的想法是制作一个单独的表并在 PHP 代码中构建一系列更改。 类似于“fieldname1 -> oldvalue | fieldname2 -> oldvalue,...”。 如果您发现此方法存在重大问题,请告诉我。

I have been asked to audit any/all changes in a MySQL table. Does anyone know of any tools out there to help me do this or do I need to write my own solution?

If I write my own audting, my initial thought it to make a separate table and build a string of changes in the PHP code. Something like "fieldname1 -> oldvalue | fieldname2 -> oldvalue, ...". If you see a major problem with this method, please let me know.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

寻梦旅人 2024-07-14 08:32:12

捕获数据库表所有更改的唯一可靠方法是在服务器上使用触发器。 修改自己的代码来审核更改的风险是来自其他应用程序/用户等的更改将不会被捕获。

话虽如此,我不确定 MySQL 4 是否支持触发器。

The only sure-fire way to capture all changes to a DB table is to use triggers on the Server. The risk of modifing your own code to audit the changes is that changes from another application/user etc will not be captured.

Having said that, I'm not sure that MySQL 4 had trigger support.

七度光 2024-07-14 08:32:12

使用 触发器 检测更改并在之前/之后写入值到日志表。

Use a trigger to detect changes and to write before/after values to a log table.

挽清梦 2024-07-14 08:32:12

如果您由于缺乏触发器支持而最终手动滚动解决方案,我强烈建议您不要只将更改转储到字符串 blob 中。 有一天,您将被要求查询该数据,而您最终将不得不进行一堆字符串解析才能取回数据。 (我在这里根据经验发言。)

最简单的方法就是创建一个影子审计表,该表具有与原始表相同的所有列,加上更改日期列和顺序 ID。 然后,您手头就有了整个历史记录,可以按照您需要的任何格式进行重建,并且可以随意查询。

If you wind up hand-rolling a solution due lack of trigger support, I strongly recommend that you don't just dump the changes in a string blob. One day you will be asked to query that data and you will wind up having to do a bunch of string parsing to get your data back out. (I speak from experience here.)

The simplest approach is just to create a shadow audit table that has all of the same columns as the original table, plus a change date column and a sequential id. Then you have the entire history at hand to reconstruct in whatever format you need, and you can query it at will.

夏天碎花小短裙 2024-07-14 08:32:12

SoftTree DB Audit 支持 MySQL,可能会满足您的要求:

http://www.softtreetech.com /idbaudit.htm

SoftTree DB Audit has MySQL support, might do what you're after:

http://www.softtreetech.com/idbaudit.htm

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文