mysql> show variables like "%long%"; <SPAN style="COLOR: #ff00ff"> //查看一下默认为慢查询的时间10秒 </SPAN> +-----------------+-----------+ | Variable_name | Value | +-----------------+-----------+ | long_query_time | 10.000000 | +-----------------+-----------+ 1 row in set (0.00 sec) mysql> set global long_query_time=1; <SPAN style="COLOR: #ff00ff">//设置成1秒,加上global,下次进mysql已然生效</SPAN> Query OK, 0 rows affected (0.00 sec) mysql> show variables like "%slow%"; <SPAN style="COLOR: #ff00ff"> //查看一下慢查询是不是已经开启 </SPAN> +---------------------+---------------------------------+ | Variable_name | Value | +---------------------+---------------------------------+ | log_slow_queries | OFF | | slow_launch_time | 2 | | slow_query_log | OFF | | slow_query_log_file | /usr/local/mysql/mysql-slow.log | +---------------------+---------------------------------+ 4 rows in set (0.00 sec) mysql> set slow_query_log='ON'; <SPAN style="COLOR: #ff00ff"> //加上global,不然会报错的</SPAN> ERROR 1229 (HY000): Variable 'slow_query_log' is a GLOBAL variable and should be set with SET GLOBAL mysql> set global slow_query_log='ON'; <SPAN style="COLOR: #ff00ff">//这个参数设置为ON,表示启用慢查询,可以捕获执行时间超过一定数值的SQL语句。</SPAN> Query OK, 0 rows affected (0.28 sec) mysql> show variables like "%slow%"; <SPAN style="COLOR: #ff00ff">//查看是否已经开启 </SPAN> +---------------------+---------------------------------+ | Variable_name | Value | +---------------------+---------------------------------+ | log_slow_queries | ON | | slow_launch_time | 2 | | slow_query_log | ON | | slow_query_log_file | /usr/local/mysql/mysql-slow.log | +---------------------+---------------------------------+ 4 rows in set (0.00 sec)
/usr/local/mysql/libexec/mysqld, Version: 5.1.26-rc-log (Source distribution). started with: Tcp port: 3306 Unix socket: /tmp/mysql.sock Time Id Command Argument # Time: 100814 13:28:30 # User@Host: root[root] @ localhost [] # Query_time: 10.096500 Lock_time: 0.045791 Rows_sent: 1 Rows_examined: 2374192 SET timestamp=1281763710; select count(distinct ad_code) as x from ad_visit_history where ad_code in (select ad_code from ad_list where media_id=15); # Time: 100814 13:37:02 # User@Host: root[root] @ localhost [] # Query_time: 10.394134 Lock_time: 0.000091 Rows_sent: 1 Rows_examined: 2374192 SET timestamp=1281764222; select count(distinct ad_code) as x from ad_visit_history where ad_code in (select ad_code from ad_list where media_id=15); # Time: 100814 13:37:16 # User@Host: root[root] @ localhost [] # Query_time: 4.608920 Lock_time: 0.000078 Rows_sent: 1 Rows_examined: 1260544 SET timestamp=1281764236; select count(*) as cou from ad_visit_history where ad_code in (select ad_code from ad_list where id=41) order by id desc;
Option h requires an argument ERROR: bad option 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 (t, at, l, al, r, ar etc), 'at' is default //排序方式query次数,时间,lock的时间和返回的记录数来排序 -r reverse the sort order (largest last instead of first) //倒排序 -t NUM just show the top n queries //显示前N多个 -a don't abstract all numbers to N and strings to 'S' -n NUM abstract numbers with at least n digits within names //抽象的数字,至 少有n位内的名称 -g PATTERN grep: only consider stmts that include this string //配置模式 -h HOSTNAME hostname of db server for *-slow.log filename (can be wildcard), //mysql所以机器名或者IP 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 //总时间中不减去锁定时间
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有