kill all mysql processes

C++
mysql> select group_concat(concat('KILL ',id,';')) from 
information_schema.processlist where user='root' and time > 500;

mysql> source /tmp/a.txt;SELECT CONCAT('KILL ',id,';') AS IDs
FROM information_schema.processlist 
WHERE TIME >10
AND command = "sleep"
sudo killall mysqld
Source

Also in C++: