首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在mysql中设置通用查询日志

问在mysql中设置通用查询日志
EN

Stack Overflow用户
提问于 2016-02-04 13:56:35
回答 1查看 1.2K关注 0票数 1

我使用的是windows 7和MySQL workbench 6.3

因此,当我开始设置日志文件时,我可以在其中获取在MySQL数据库上触发的所有查询。我卡得太厉害了。

C:\Program Files\MySQL1\MySQL Server5.7,之后应该会有任何my.ini文件,根据谷歌上数百万篇文章的说法。但是我有我的-default.ini。:(

这是我的my-default.ini文件

代码语言:javascript
复制
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.

[mysqld]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....


# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M 

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
log=file.log
general-log=1
general-log-file=file.log

我刚刚添加了最后3行,这样我就可以在file..but中获得日志,即使是bin中的文件file.log也没有得到任何东西。

有没有人能帮我设置一下?提前感谢!!

EN

回答 1

Stack Overflow用户

发布于 2016-02-04 14:03:08

首先执行下面的命令来启动通用日志-

代码语言:javascript
复制
SET general_log=ON;

现在,通过以下命令检查您的服务器将它们写入的位置-

代码语言:javascript
复制
SHOW VARIABLES LIKE 'general_log_file';

现在转到服务器,您可以阅读这些日志,在linux中,您可以使用tail命令-

代码语言:javascript
复制
tail -f /var/log/mysqd_query.log 

注意:这里的路径和文件是var/log/mysqd_query.log

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35193539

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档