MySQL DBA - Tips and Techniques Magazine

11 Nov 2014

Batch kill mysql processes

In 5.1 onwards:

 

select concat('KILL ',id,';') from information_schema.processlist where user='root'  and …;

 

For all versions:

 

dbname=sales_site

dbuser=portal

 

 

#!/bin/bash

for each in `$MYSQLADMIN_CONNECT processlist | awk '{print $2,$4,$8}' | grep $dbname  | grep $dbuser | awk '{print $1}'`

do $MYSQLAMDIN_CONNECT kill $each;
done

No comments:

Post a Comment