MySQL 管理长时间运行查询
发表于:2025-02-03 作者:千家信息网编辑
千家信息网最后更新 2025年02月03日,最常用的查询select concat ('kill ',id,';') from information_schema.processlist where time >= 2 -
千家信息网最后更新 2025年02月03日MySQL 管理长时间运行查询
最常用的查询
select concat ('kill ',id,';') from information_schema.processlist where time >= 2 -- and user = '业务账号' and command not in ('sleep','Connect') and state not like ('waiting for table%lock'); and info like '%Metabase%'mysql -uroot -s -N -p -h -e "select concat ('kill ',id,';') from information_schema.processlist where INFO like 'SELECT xxx FROM%' " > kill.sql
RDS提供的存储过程:
create event my_long_running_query_monitoron schedule every 5 minutestarts '2015-09-15 11:00:00'on completion preserve enable dobegin declare v_sql varchar(500); declare no_more_long_running_query integer default 0; declare c_tid cursor for select concat ('kill ',id,';') from information_schema.processlist where time >= 3600 and user = substring(current_user(),1,instr(current_user(),'@')-1) and command not in ('sleep') and state not like ('waiting for table%lock'); declare continue handler for not found set no_more_long_running_query=1; open c_tid; repeat fetch c_tid into v_sql; set @v_sql=v_sql; prepare stmt from @v_sql; execute stmt; deallocate prepare stmt; until no_more_long_running_query end repeat; close c_tid;end;
参考:https://help.aliyun.com/knowledge_detail/41735.html?spm=a2c4g.11186631.2.20.51106998SvntYb
RDS中的参数
loose_max_statement_time
管理长查询的shell脚本
#!/bin/bashpassword=xxxxxxmysql -uroot -p$password -N -s -e "select concat ('kill ',id,';') from information_schema.processlist where time >= 300 -- and user = '业务账号' and command not in ('sleep','Connect') and state not like ('waiting for table%lock');" > killmysqlsession.txt#cat killmysqlsession.txt | while read line#do#echo $line#mysql -uroot -p$password -e "$line"#donemysql -uroot -p$password < killmysqlsession.txt#或者登陆实例source killmysqlsession.txt
查询
业务
账号
管理
参数
实例
常用
脚本
过程
参考
存储
登陆
长时
运行
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
帝国cms修改数据库权限
网络安全运维工程师有前途吗
网络安全意识儿童手抄报图片
萨尔服务器
建好的数据库找不到了
qt读取数据库卡死
网络安全中常见的攻击方式
网络安全责任制台账
服务器2u机架式
分析网络安全问题有哪些
无锡宝通科技有限公司互联网
底盘软件开发岗
网络安全销售业绩 提成
gen8 服务器
cf残端服务器已满补丁
二次元网络技术大全
服务器防护柜怎么开启
软件开发工作日志英文
三级数据库划线怎么打出来
捷云软件开发
软件开发需求分析师英文简称
北京国企网络安全维护招聘
竞技世界成都网络技术公司
数据库的应用有哪些
mysql数据库的由来PPT
h310 支持服务器cpu
江西省网络技术设备研究所
我的世界服务器武器
顺义区大规模软件开发设计
多串口服务器只有一个串口能用