"Reprint" MySQL is slow sql hang, with shell script to quickly clear the growing slow SQL method

Source: Internet
Author: User

The original address: MySQL is slow sql hang, with shell script to quickly clear the growing slow SQL method MCHDBA

A novice DBA mistakenly deleted index,mysql is all over 10S slow sql,mysql service is hang, and slow SQL constantly in the increase, if manually in the MySQL interface kill, it is too late, this time, the shell must be shot, As the shell script below, you can refer to:

#It is used to kill processlist of MySQL sleep#!/bin/shwhile:d o  n= ' mysqladmin processlist-uadmin-pxxxxx|grep-i SLE EP |wc-l '  date= ' date +%y%m%d\[%h:%m:%s] '  echo $n  if ["$n"-gt] then  -  i in ' mysqladmin process List-uadmin-pxxxxxx|grep-i sleep |awk ' {print $} ' do     mysqladmin-uadmin-pxxxxxx kill $i done  Echo ' Sleep is too many I killed it ">>/tmp/sleep.log  echo" $date: $n ">>/tmp/sleep.log  fi                 Sleep 1done


Finally, quickly add the appropriate index!

"Reprint" MySQL is slow sql hang, with shell script to quickly clear the growing slow SQL method

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.