Linux.com

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 ;-)

#/bin/sh

AWK=/usr/awk

ADMIN_PATH=/usr/local/bin

$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

 

Comments

Subscribe to Comments Feed

Upcoming Linux Foundation Courses

  1. LFD211 Introduction to Linux for Developers
    08 Dec » 09 Dec - Virtual
    Details
  2. LFS220 Linux System Administration
    08 Dec » 11 Dec - Virtual
    Details
  3. LFS520 OpenStack Cloud Architecture and Deployment
    08 Dec » 11 Dec - Virtual
    Details

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