在哪里可以找到 MySQL 事务日志?
MySQL 是否保留事务日志?如果有,我在哪里可以找到它?
许多行被神秘地从表中删除,我想尝试看看它是如何以及何时发生的。
Does MySQL keep a transaction log and if so where could I find it?
A number of rows have mysteriously been deleted from a table and I want to try and see how and when it occurred.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果你打开 - mysql可以跟踪二进制日志,其中包含所有修改(要清楚 - 它包含已更改某些内容的查询)。
但无论如何,如果您没有在二进制日志打开之前进行的初始转储,那么它是没有用的。另外我想如果你进行转储并打开二进制日志 - 你就不会问这样的问题:-S
If you turned on - mysql can track binary log, which contains all the modifications (to be clear - it contains the queries that had changed something).
But anyway, it is useless if you do not have the initial dump, which precedes the binlog turning on. Also i suppose if you made the dump and turned on binlog - you would not ask such question :-S
简短回答:默认情况下不是。
为了获得准确的日志记录结果,您需要首先使用参数
--log-bin=your-file-name
以二进制日志记录模式启动服务器。然后,它创建一个二进制日志文件 {your-file-name.seq},其中seq
是后续日志文件的序列号(建议将您的文件名放在那里,并具有明确的目录位置)。有关解释所有详细信息的 MySQL 站点的更多信息: https:// /dev.mysql.com/doc/refman/5.7/en/binary-log.html
Short answer: not by default.
In order to have accurate logging results, you need to have started the server in binary logging mode first, using the parameter
--log-bin=your-file-name
. It then creates a binary log file {your-file-name.seq} whereseq
is a sequence number for subsequent log files (recommended to put your file name there, with explicit directory location).More information on the MySQL site explaining all the details: https://dev.mysql.com/doc/refman/5.7/en/binary-log.html
如果您在 Windows 上使用 MySql,则在
C:\Program Files\MySQL\MySQL Server 5.0\data
中有一个文件(假设安装目标为 C: 驱动器且 MySql 版本为 5.0),名为 %COMPUTERNAME%.log 的文件包含已执行的命令。If you're using MySql on Windows, there's a file located in
C:\Program Files\MySQL\MySQL Server 5.0\data
(assuming a C: drive for the installation target and MySql version 5.0), that is called %COMPUTERNAME%.log that contains the commands that have been executed.