Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save psahni/1027031 to your computer and use it in GitHub Desktop.
Save psahni/1027031 to your computer and use it in GitHub Desktop.
MySQL Connection Cleaner
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