mysql 慢查询

vim my.conf

log-queries-not-using-indexes  = 0  #把慢查询以及执行时没有使用索引的查询命令全都记入日志(其余同--log-slow-queries选项)。
slow-query-log                 = 1
long_query_time                = 2  #慢查询的执行用时上限(默认设置是10s)。
slow-query-log-file            = /data/mysql/mysql-slow.log

show variables like “%slow%”; #查看慢查询配置


  --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 //top NUM 常用
  -a           don't abstract all numbers to N and strings to 'S' //不使用N S来代替‘变量’
  -n NUM       abstract numbers with at least n digits within names
  -g PATTERN   grep: only consider stmts that include this string // grep ‘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

mysqldumpslow -s t -t 10 -a -g  "like" /log/mysql/slowbak.log #按查询时间排序 包括like字符的前十个

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值