MySql:如何通过my.cnf开启通用查询日志?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11286626/
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
MySql: How to turn on the general query log via my.cnf?
提问by Wolfpack'08
I'm trying to use a program called MySql Administrator, though I'd also be willing to use the Command Prompt (I am on Windows XP). Typically I start MySql via the XAMPP control panel, and I would like to make it so that MySql monitors changes to at least two of my databases. Because I don't make a lot of changes, just keeping a log turned on all the time wouldn't be an issue.
我正在尝试使用名为 MySql Administrator 的程序,但我也愿意使用命令提示符(我使用的是 Windows XP)。通常,我通过 XAMPP 控制面板启动 MySql,并且我想让 MySql 监视对我的至少两个数据库的更改。因为我没有做太多更改,所以只要保持日志一直打开就不会成为问题。
Ideally, I the changes made to the database will be visible via a log file that updates each time a query is made. If that isn't possible, being able to check via MySql Administrator or via the MySql command line would be fine. I'm not sure how to configure MySql to always start with the log on, though. Is that possible? If so, how is it done? Please, tell me the specific location of the files that need to be edited, also. I've been told to edit my my.cnf, but there are many my.cnf-type files in MySql's subdirectories. So, I need to know what specifically to do, without any of the ambiguity....
理想情况下,对数据库所做的更改将通过每次进行查询时更新的日志文件可见。如果这是不可能的,能够通过 MySql 管理员或通过 MySql 命令行进行检查就可以了。不过,我不确定如何配置 MySql 以始终从登录开始。那可能吗?如果是这样,它是如何完成的?请告诉我需要编辑的文件的具体位置。有人告诉我要编辑 my.cnf,但 MySql 的子目录中有许多 my.cnf 类型的文件。所以,我需要知道具体要做什么,没有任何歧义....
回答by Wolfpack'08
You can enable it via MySQL Administrator in the settings->logging tab, but I don't think that this actually enables logging. When I turned it on, restarted MySQL, restarted MySQL Administrator, restarted my system, etc., the log file never came up. I edited the my.ini file, in the base MySQL directory. I found the line log=
and altered it, also adding a couple lines after:
您可以通过 MySQL Administrator 在设置->日志记录选项卡中启用它,但我认为这实际上并没有启用日志记录。当我打开它、重新启动 MySQL、重新启动 MySQL Administrator、重新启动我的系统等时,日志文件从未出现。我在基本 MySQL 目录中编辑了 my.ini 文件。我找到了该行log=
并对其进行了更改,并在之后添加了几行:
log = "you_name_it_query.log"
general-log=1
general-log-file = "you_name_it_query.log"
I was then able to browse the general query log via MySQL administrator.
然后我就可以通过 MySQL 管理员浏览一般查询日志。
I also used some programs mentioned here: https://superuser.com/questions/443499/detect-and-monitor-changes-to-mysql-databaseand here: Compare two MySQL databasesfor my purpose. There are some logging options in some of the programs mentioned by the asker.
我还使用了这里提到的一些程序:https: //superuser.com/questions/443499/detect-and-monitor-changes-to-mysql-database和这里:为我的目的比较两个 MySQL 数据库。提问者提到的一些程序中有一些日志记录选项。