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. LFS230 Linux Network Management
    06 Oct » 09 Oct - Virtual
    Details
  2. LFD331 Developing Linux Device Drivers
    13 Oct » 17 Oct - Virtual
    Details
  3. LFS430 Linux Enterprise Automation
    13 Oct » 16 Oct - 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