I need an efficient way to disconnect all clients with a given username from MySQL. I thought about changing the users password but I think that is only checked when the connection is made.
Ideas?
|
I need an efficient way to disconnect all clients with a given username from MySQL. I thought about changing the users password but I think that is only checked when the connection is made. Ideas? |
|||
|
|
|
You could use "SQL to SQL" method below (just pass in extra connection options to mysql client as needed):
Note: This works with MySQL 5.1 and 5.5. This would have to be implemented differently for older MySQL versions as information_schema does not have the processlist table. Options used:
Explanation of how it works: First the KILL statements are generated along with IDs.
Sample output:
Then those statements are executed.
Sample output:
|
||||
|
|