How might one mass kill connections to MySQL?
I've opened too many connections to MySQL and now I can't access it. It says "Too many connections". How can I close all of these connections? I also don't know how to restart it, which may resolve the problem.
Solution 1:
I answered this question on mass killing DB Connections in the DBA StackExchange back in May 2011.
What can allow a person to login to mysql under such stressful conditions? The answer is quite simple : DO NOT GIVE EVERYBODY THE SUPER PRIVILEGE !!!
Why the SUPER Privilege ?
According to the MySQL Documentation:
The SUPER privilege enables an account to use CHANGE MASTER TO, KILL or mysqladmin kill to kill threads belonging to other accounts (you can always kill your own threads), PURGE BINARY LOGS, configuration changes using SET GLOBAL to modify global system variables, the mysqladmin debug command, enabling or disabling logging, performing updates even if the read_only system variable is enabled, starting and stopping replication on slave servers, specification of any account in the DEFINER attribute of stored programs and views, and enables you to connect (once) even if the connection limit controlled by the max_connections system variable is reached.
In light of this, regular client connections should not have SUPER privilege. Once the number of DB Connections reached = max_connections, only one more connection will be allowed and that one connetion has to have SUPER privilege. If everyone and his grandmother has the SUPER privilege, all bets are off and nobody can login.
Solution 2:
You have the three following options:
Start -> Run -> Services.msc
Find MySQL, rightclick and choose restartStart -> Run -> CMD
net stop MySQL enter
net start MySQL enter- Kill all instances of mySQLd.exe in the taskpanel. (not recommended)