要想执行mysqldumpslow.pl(这是perl程序),下载perl编译器。

下载地址:http://pan.baidu.com/s/1i3GLKAp

就是ActivePerl_5.16.2.3010812913.msi,一步一步安装后,将bin增加环境变量path。

如今如果一个场景:现场的slow.log拿回来了,要在本地的windows环境上的mysql上分析。怎样处理?

C:\Program Files\MySQL\MySQL Server 5.6\bin>perl mysqldumpslow.pl --help

Usage: mysqldumpslow [ OPTS... ] [ LOGS... ]

Parse and summarize the MySQL slow query log. Options are

  --verbose    verbose

  --debug      debug

  --help       write this text to standard output





  -v           verbose

  -d           debug

  -s ORDER     what to sort by (al, at, ar, c, l, r, t), 'at' is default

                al: average lock time

                ar: average rows sent

                at: average query time

                 c: count

                 l: lock time

                 r: rows sent

                 t: query time

  -r           reverse the sort order (largest last instead of first)

  -t NUM       just show the top n queries

  -a           don't abstract all numbers to N and strings to 'S'

  -n NUM       abstract numbers with at least n digits within names

  -g PATTERN   grep: only consider stmts that include this string

  -h HOSTNAME  hostname of db server for *-slow.log filename (can be wildcard),

               default is '*', i.e. match all

  -i NAME      name of server instance (if using mysql.server startup script)

  -l           don't subtract lock time from total time

1. -s,排序,c,t,l,r以及ac,at,al,ar各自是依照query次数。时间,lock时间,返回记录排序。加a就是倒序。

2. -t,top n。跟上数字就是算出top多少条

3. -g。跟正則表達式。

C:\Program Files\MySQL\MySQL Server 5.6\bin> mysqldumpslow.pl -r -s c -a -t    > E:\slow.txt

假设运行这个会报错,就依照报错信息来,在my.ini中加入一些參数就可以。

分析的结果在slow.txt中,例如以下:

Count: 23  Time=505.55s (11627s)  Lock=0.00s (0s)  Rows=30740.8 (707039), username[password]@[10.194.172.41]

  SELECT DISTINCT u.name,o.full_name FROM pub_user u,pub_user_org uo,pub_org o WHERE  u.user_id=uo.user_id

  AND uo.org_id=o.org_id and u.del_flag=N and uo.del_flag=N

  and u.account not like 'S' and u.account not like 'S' group by u.user_id



Count: 4  Time=375.01s (1500s)  Lock=0.00s (0s)  Rows=10200.3 (40801),
username[password]@[10.194.172.41]

  select distinct username,pu.name, po.full_name from pub_login_history as plh

  inner join pub_user as pu on plh.username=pu.user_id

  inner join pub_user_org as puo on pu.user_id=puo.user_id

  inner join pub_org as po on puo.org_id=po.org_id

  where TIMESTAMPDIFF(MINUTE,login_time,logout_time)>=N

  and login_time>'S' and login_time<'S'

Count: 4(运行了多少次)  Time=375.01s(每次运行的时间) (1500s)(一共运行了多少时间)  Lock=0.00s (0s)(等待锁的时间)
 Rows=10200.3(每次返回的记录数) (40801)(总共返回的记录数), username[password]@[10.194.172.41]

windows下mysql5.6.20使用mysqldumpslow.pl分析慢日志的更多相关文章

  1. windows下MySQL5.6以上版本,如何通过修改配置文件来修改数据库的最大连接数啊?

    并没有my.ini文件,只有一个my-default.ini文件,并且里面并没有max_connections windows下MySQL5.6以上版本,如何通过修改配置文件来修改数据库的最大连接数啊 ...

  2. windows管理员利器之用Log Parser Studio分析IIS日志(附逐浪CMS官方命令集)

    原文:windows管理员利器之用Log Parser Studio分析IIS日志(附逐浪CMS官方命令集) Log Parser Studio是一个强大的IIS图形分析工具,值得推荐. 1. 安装L ...

  3. 安装MYSql Windows7下MySQL5.5.20免安装版的配置

    MySQL Windows安装包说明: 1.mysql-5.5.20-win32.msi:Windows 安装包,图形化的下一步下一步的安装. 2.mysql-5.5.20.zip,这个是window ...

  4. windows下mysql5.7安装及配置

    装完msi后,复制my-default.ini文件,黏贴为my.ini文件,内容修改如下: # For advice on how to change settings please see# htt ...

  5. linux下 mysql5.7.20安装(精华)

    在linux 系统中mysql配置文件的读取顺序为: /etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf 第一步 创 ...

  6. windows下Mysql5.7表名不区分大小写问题

    前言 Windwos文件系统本身是不区分大小写的,但是Linux文件系统是支持大小写的.于是安装在Linux下的Mysql导出到windows下可能因为大小写问题导致错误,因此要开启window下My ...

  7. windows下mysql5.6.x的日志正确配置方法(my.ini) (网上的都是5.6之前的版本)

    https://blog.csdn.net/databatman/article/details/49951853 感谢楼主,找了好久,试了一下楼主的,果然是对的,网上的日志配置都是5.6之前的版本: ...

  8. 转载-windows下MySql5.6.17没有setup.exe时的安装方法

    转载出处为:http://blog.csdn.net/zgrjkflmkyc/article/details/25321537 (最终,我也没有安装下述的方法安装成功,虽然有服务,但是服务启动不正常, ...

  9. Windows下MySQL5.6.21安装步骤

    01.把 mysql-advanced-5.6.17-winx64.zip 解压到自定义 D:\mysql-5.6.17-W64 或 D:\mysql-advanced-5.6.17-winx64 目 ...

随机推荐

  1. android切换卡顿解决方法

    如果想要让应用用户流畅的滑动体验的话,那么就必须对activity和fragment的生命周期有一个完整的概念以及在何种情况下会触发哪些事件. 在自己目前做的项目中,就遇到了这样的问题,那么就把自己的 ...

  2. POJ 1149 PIGS (AC这道题很不容易啊)网络流

    PIGS Description Mirko works on a pig farm that consists of M locked pig-houses and Mirko can't unlo ...

  3. 关于TJOI2014的一道题——Alice and Bob

    B Alice and Bob •输入输出文件: alice.in/alice.out •源文件名: alice.cpp/alice.c/alice.pas • 时间限制: 1s 内存限制: 128M ...

  4. MySQL学习笔记之右连接

    MySQL的右连接 #右连接,以右表为基表 select course.stuid,course.stuname,sex,course,city from class1 right join cour ...

  5. Spring Boot (17) 发送邮件

    添加依赖 <!--发送邮件 --> <dependency> <groupId>org.springframework.boot</groupId> & ...

  6. 自学Python八 爬虫大坑之网页乱码

    Bug有时候破坏的你的兴致,阻挠了保持到现在的渴望.可是,自己又非常明白,它是一种激励,是注定要被你踩在脚下的垫脚石! python2.7中最头疼的可能莫过于编码问题了,尤其还是在window环境下, ...

  7. Objective-C—— Block

    OC Block 其实功能就类似C语言的函数指针,js中的闭包之类的.把代码块当做一个变量就行操作,有自己的变量和作用域. 简单看一下Block的语法和可能出现的问题: Block语法: block语 ...

  8. MxNet : use the MxNet windows versioin

    The MxNet needs  the following thirdparties: 1. lapack complie lapack-3.6.1: download the lapack-3.6 ...

  9. idea搭建第一个springboot

    1.打开idea开发工具,在菜单栏选择File-->New-->Project...-->Spring Initializer说明:社区版的idea是没有Spring Initial ...

  10. ptyhon获取app设备号、包名、activity

    直接上代码: import time import os import re import sys #------------------------------------------------- ...