bloginfo('name');

bloginfo('description');

Little bash snippet to kill locking queries from MySQL

Oktober 9th, 2008 by Blu:RayNe

I just tell you: optimize your tables! I will not give anymore support for bad code, stupid database layout and i am not going to debug your messy code. If you don’t get the introductino chapters of MySQL – stay away from me! Yep, it was just one of these days…

#!/bin/bash
echo "Killing MySQL Queries…"
MYSQL="$(which mysql)"
MyUSER="username"
MyPASS="password"

for pid in `mysqladmin proc  -u$MyUSER -p$MyPASS | grep -i Query  | grep -i lock|awk ‘{ print $2;}’`
do
        query="KILL $pid;"
        echo "> $query";
        $MYSQL -u$MyUSER  -p$MyPASS -e "$query"
done;

Filed under Datenbanken having

Leave a Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.