Saturday, April 15, 2023

Mysql: Kill a session

 In Mysql, If we want to kill the multiple sessions quickly. Use below sql statement to generate the "KILL statements for the ID's and decide based on the once to kill.


 SELECT GROUP_CONCAT(CONCAT('KILL ',id ,'  ' ,HOST ,';')) FROM information_schema. processlist WHERE user <> 'system user'

 group by ID; 

 

example:

KILL 1  localhost;

KILL 24905  localhost2:1234;

No comments:

Post a Comment

PostgreSql: Useful Commands-

 1)   ************************* Users ***************************  -- List of users with roles assigned: SELECT usename AS role_name,   CASE...