How does MYSQL view processes and kill processes
This article mainly explains "MYSQL how to view the process and kill the process", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let Xiaobian take you to learn "MYSQL how to view processes and kill processes"!
How to view processes and kill processes
Sometimes when we execute an SQL statement or change the table structure, due to the huge amount of data in this table, we often get stuck after executing the operation…and then this table will be locked. At this point, we can kill the process.
There are two ways to view and kill processes
The first SHOW PROCESSLIST;
Executing the above command, you can see the following figure:
Then find the corresponding ID:
KILL 41515;
That's OK.
the second
You need tools, Navicat. Tools-> Server Monitoring->MySQL
After opening it, you can see the following picture:
Then, he still found the corresponding ID:
KILL 42736;kill all slow query processes and lock table processes 1, kill all slow query processes #!/ bin/bashmysql -uroot -pMy_Password -e "show processlist" | grep -i "Query" > slow_query.logfor query in `cat slow_query.log | awk '{print $1}'`do echo "kill $query;" > kill_slow_query.sqldone
Log in to mysql and execute:
mysql> source kill_slow_query.sql
Or:
#!/ bin/bashfor query in `mysqladmin -uroot -pMy_Password processlist | grep -i 'Query' | awk '{print $2}'`do mysqladmin kill ${query}done2, kill all deadlock processes #!/ bin/bashmysql -uroot -pMy_Password -e "show processlist" | grep -i "Locked" > locked.logfor lock in `cat locked.log | awk '{print $1}'`do echo "kill $lock;" > kill_locked.sqldone
Log in to mysql and execute:
mysql> source kill_locked.sql
Or:
#!/ bin/bashfor lock in `mysqladmin -uroot -pMy_Password processlist | grep -i 'Locked' | awk '{print $2}'`do mysqladmin kill ${lock}done Here, I believe everyone has a deeper understanding of "MYSQL how to view the process and kill the process", may wish to actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!