patternsqlMinor
Linux command to kill all MySQL sessions from a specific User?
Viewed 0 times
killallusermysqllinuxspecificcommandfromsessions
Problem
How can i kill all sessions from a user in mysql using a linux command line command?
I have a user that is using all on my database connections and insted of killing one by one i want to make a script to kill them all !
I have a user that is using all on my database connections and insted of killing one by one i want to make a script to kill them all !
Solution
Try this :
The command will list the processes running in the database and return a
Be carefull with this command as there is no rollback form it :)
mysql -uuser -ppassword -e 'show processlist' | grep USER_NAME | awk {'print "kill "$1";"'}| mysql -uuser -ppasswordThe command will list the processes running in the database and return a
kill 'query id'; command and pipe it into mysql again.Be carefull with this command as there is no rollback form it :)
Code Snippets
mysql -uuser -ppassword -e 'show processlist' | grep USER_NAME | awk {'print "kill "$1";"'}| mysql -uuser -ppasswordContext
StackExchange Database Administrators Q#61531, answer score: 5
Revisions (0)
No revisions yet.