在 MySQL Bin 日志中搜索查询
是否可以查询 mysql bin 日志中的特定查询?例如,假设我想知道过去一小时内是否有人执行了特定查询(例如“Update tableX where userName = 'bob'”)。我只想查看最近是否运行了特定查询......
Is it possible to query the mysql bin log for a particular query? For example, suppose I want to know if anyone in the last hour did a specific query (like 'Update tableX where userName = 'bob'"). I just want to see if a particular query has been run recently.....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用mysqlbinlog - nix或mysqlbinlog.exe - windows
转换后可以在mysql_bin.txt中搜索DML
Use mysqlbinlog - nix or mysqlbinlog.exe - windows
After conversion You can search DML in mysql_bin.txt
也许MySQL通用查询日志可以帮助你。
Maybe MySQL general query log can help you.
赞成的答案对我没有帮助。原因是
mysqlbinlog
使用 BINLOG 语句可由服务器读取,但不能用于过滤查询。但幸运的是,有
-v
选项 重建查询并允许进行搜索。此选项适用于 MySQL 5.7 和 8。使用此命令检查 mytable 是否已更新:
The upvoted answer did't help me. The reason is that
mysqlbinlog
uses BINLOG statement which is readable by server and it can't be used to filter queries.But fortunately there's the
-v
option which reconstructs the query and allows to make searches. This option applies both to MySQL 5.7 and 8.Use this command to check if mytable was updated: