-
-
Save psahni/1027031 to your computer and use it in GitHub Desktop.
MySQL Connection Cleaner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mysql2' | |
client = Mysql::Client.new(:host => "localhost", :username => "root") | |
# Fetch running threads | |
processes = client.query("SHOW FULL PROCESSLIST") | |
processes.each do |process| | |
# Kill thread | |
client.query("KILL #{process[0].to_i}") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment