Home Linux Community Community Blogs General Linux MySQL admin emergency processlist kill script

MySQL admin emergency processlist kill script

Ever been caught off guard by a user running a daft query against the database thats causing everything to stack up??

This script is a quick and dirty way to get rid of everything that active ‘now’, and has been used on occasions where users have run a query that locks a table thats required elsewhere, but they havent checked the impact of their changes. Its not a good way to run things, but can help temporarily sort service issues, particularly when no one will admit that they are the person thats run a dodgy query ;-)




$ADMIN_PATH/mysqladmin processlist -h127.0.0.1 -p<password>|$AWK ‘{ print $2}’ > processes.txt
for i in `cat processes.txt`; do $ADMIN_PATH/mysqladmin -h127.0.0.1 -p<password> kill $i; echo “killed $i”; done



Subscribe to Comments Feed

Upcoming Linux Foundation Courses

  1. LFS426 Linux Performance Tuning
    08 Sep » 11 Sep - New York
  2. LFS520 OpenStack Cloud Architecture and Deployment
    08 Sep » 11 Sep - Virtual
  3. LFD320 Linux Kernel Internals and Debugging
    15 Sep » 19 Sep - Virtual

View All Upcoming Courses

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board