Windows下MySQL开启历史记录

打开my.ini文件,位置安装目录下,添加开启日志的配置,重启mysql

# SERVER SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this 
# file.
#
[mysqld]
# Set Slow Query Log
long_query_time = 1
slow_query_log = 1
slow_query_log_file = "slowquery.log"
#Set General Log
log = "genquery.log"

 

slow_query_log_file、log 的文件位置可以自己制定绝对路径,默认在数据文件夹下。

long_query_time单位为秒,即大于1秒的查询语句将记录在slowquery.log文件中。

log 是执行的SQL语句都将记录下来。

如下:

150315 12:06:20     2 Query SET PROFILING=1
      2 Query SHOW STATUS
      2 Query SHOW STATUS
      2 Query use jeewx
      2 Query select * from weixin_account
      2 Query SHOW STATUS
      2 Query SELECT QUERY_ID, SUM(DURATION) AS SUM_DURATION FROM INFORMATION_SCHEMA.PROFILING GROUP BY QUERY_ID
      2 Query SELECT STATE AS `Status`, ROUND(SUM(DURATION),7) AS `Duration`, CONCAT(ROUND(SUM(DURATION)/0.000659*100,3), '%') AS `Percentage` FROM INFORMATION_SCHEMA.PROFILING WHERE QUERY_ID=8 GROUP BY STATE
      2 Query SELECT * FROM `jeewx`.`weixin_account` LIMIT 0
      2 Query SHOW COLUMNS FROM `jeewx`.`weixin_account`
150315 12:12:19     2 Query SET PROFILING=1
      2 Query SHOW STATUS
      2 Query SHOW STATUS
      2 Query use jeewx
      2 Query select * from weixin_account
      2 Query SHOW STATUS
      2 Query SELECT QUERY_ID, SUM(DURATION) AS SUM_DURATION FROM INFORMATION_SCHEMA.PROFILING GROUP BY QUERY_ID
      2 Query SELECT STATE AS `Status`, ROUND(SUM(DURATION),7) AS `Duration`, CONCAT(ROUND(SUM(DURATION)/0.000351*100,3), '%') AS `Percentage` FROM INFORMATION_SCHEMA.PROFILING WHERE QUERY_ID=18 GROUP BY STATE
      2 Query SELECT * FROM `jeewx`.`weixin_account` LIMIT 0
      2 Query SHOW COLUMNS FROM `jeewx`.`weixin_account`
150315 12:22:39     1 Query id
150315 12:22:47     1 Query show database
150315 12:22:49     1 Query show databases
150315 12:22:55     1 Query use test
150315 12:23:27     1 Query create table testtable(
 
id integer,
 
name varchar(32))
150315 12:23:31     1 Query show tables

 

 

你可能感兴趣的:(Windows下MySQL开启历史记录)