打開my.ini文件,位置安裝目錄下,添加開啓日誌的配置,重啓mysqljava
# 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 的文件位置能夠本身制定絕對路徑,默認在數據文件夾下。mysql
long_query_time單位爲秒,即大於1秒的查詢語句將記錄在slowquery.log文件中。sql
log 是執行的SQL語句都將記錄下來。this
以下:spa
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 id150315 12:22:47 1 Query show database150315 12:22:49 1 Query show databases150315 12:22:55 1 Query use test150315 12:23:27 1 Query create table testtable( id integer, name varchar(32))150315 12:23:31 1 Query show tables |