我在哪里可以找到 MySQL 事务日志?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3394132/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 16:44:22  来源:igfitidea点击:

Where can I find the MySQL transaction log?

mysqltransaction-log

提问by php-b-grader

Does MySQL keep a transaction log and if so where could I find it?

MySQL 是否保留事务日志,如果有,我在哪里可以找到它?

A number of rows have mysteriously been deleted from a table and I want to try and see how and when it occurred.

从表中神秘地删除了许多行,我想尝试看看它是如何以及何时发生的。

采纳答案by zerkms

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).

如果您打开 - mysql 可以跟踪二进制日志,其中包含所有修改(要清楚 - 它包含已更改某些内容的查询)。

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

但无论如何,如果您没有在打开 binlog 之前的初始转储,则它是无用的。另外我想如果你进行了转储并打开了 binlog - 你不会问这样的问题:-S

回答by Rob

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.

如果您在 Windows 上使用 MySql,则有一个文件位于C:\Program Files\MySQL\MySQL Server 5.0\data(假设安装目标为 C: 驱动器且 MySql 版本为 5.0),名为 %COMPUTERNAME%.log,其中包含已执行的命令。

回答by Stephan van Ingen

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 <> where seqis a sequence number for subsequent log files (recommended to put your file name there, with explicit directory location).

为了获得准确的日志结果,您需要先以二进制日志模式启动服务器,使用参数--log-bin=your-file-name. 然后它创建一个二进制日志文件 <> ,其中seq是后续日志文件的序列号(建议将您的文件名放在那里,并带有明确的目录位置)。

More information on the MySQL site explaining all the details: https://dev.mysql.com/doc/refman/5.7/en/binary-log.html

有关解释所有详细信息的 MySQL 站点的更多信息:https: //dev.mysql.com/doc/refman/5.7/en/binary-log.html