如何找出MySQL数据库在给定时间内执行的所有命令?
是否可以找出给定时间范围内对数据库执行的所有命令?例如,我想知道过去 24 小时内谁对数据库表执行了插入命令。
任何帮助将不胜感激。
谢谢。
Is it possible to find out all the command executed against a database in a given timeframe? For example, I would like to know who executed insert command on a database table in the last 24 hours.
Any help would be greatly appreciated.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于更改数据的查询,您可以检查二进制日志。但是,我认为这不会让您获得用户:
要获得用户,您需要在表上设置触发器并使用这些触发器将审核日志存储在另一个表中。
如果您需要所有查询(包括选择),还有 常规查询日志,但由于性能影响和磁盘要求,该日志通常不会打开。
For queries which change data, you can check the binary log. However, I don't think this'll get you the user:
To get the user, you'll need to set up triggers on the tables and use those triggers to store an audit log in another table.
If you need to all queries—selects included—there is also the general query log but that is not normally on due to performance impacts and disk requirements.
http://dev.mysql.com/doc/refman/ 5.0/en/binary-log.html
二进制日志可能会有所帮助。
http://dev.mysql.com/doc/refman/5.0/en/binary-log.html
Binary log might help a bit.