MySQL: Killing connections massively - Userlinux.net

Every so often I run into situation when I need to kill a lot of connections on MySQL server - for example hundreds of instances of some bad query is running making server unusable. Many people have special scripts which can take the user, source host or query as a…

MySQL: Killing connections massively

26.May.2009 ~ 1 Comentarios ~ 1162 Lecturas
Every so often I run into situation when I need to kill a lot of connections on MySQL server - for example hundreds of instances of some bad query is running making server unusable. Many people have special scripts which can take the user, source host or query as a parameter and perform the action. There is also a way to do it just using MySQL with a few commands:
mysql> SELECT concat('KILL ',id,';') FROM information_schema.processlist WHERE user='root';
+------------------------+
| concat('KILL ',id,';') 
+------------------------+
| KILL 3101;			 
| KILL 2946;			 
+------------------------+
2 rows IN SET (0.00 sec)
mysql> SELECT concat('KILL ',id,';') FROM information_schema.processlist WHERE user='root' INTO OUTFILE '/tmp/a.txt';
Query OK, 2 rows affected (0.00 sec)
mysql> source /tmp/a.txt;
Query OK, 0 rows affected (0.00 sec)
Fully copypasted from MySQL Performance Blog.
Categorías: programación
Tags: mysql

Comentarios


gravatar
27.May.2009
Buena esa!

A veces cuando haces un show processlist y ves que se avecina una catástrofe... puede ser útil :)

Comentarios


Los comentarios están cerrados: los comentarios se cierran automáticamente una vez pasados 15 días. Si quieres comentar algo acerca de la anotación, puedes hacerlo por e-mail.

Buscar

Cargando...

Últimos comentarios

  • Juan
  • Marina
  • Francisco
  • fon
  • minWi
  • isra
  • reidrac
  • r0sk
  • Rodrigo Rega
  • minWi
  • r0sk
  • reidrac
  • r0sk
  • deady
  • errece

Moneting

Valor de mi cuenta de Facebook según Moneting
Valor de mi cuenta de Twitter según Moneting

Tagcloud

ssh frases champions userlinux iphone lugo rsidenotes felicidades films nintendo opinion sysadmin 2008 blogsfera vacaciones juegos cake ds debian sidenotes apple web blogs mac mysql cakephp deportes 2007 mundial openbsd barça ubuntu twitter blog humor meme canción alemania_2006 games bsd lucux linux twitt programación cumpleaños software django league bash macosx ps3 rfilms conciertos freebsd seguridad personal hack php bake futbol

Archivo

Social

Enlaces de interés