Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does MYSQL view processes and kill processes

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report