Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/ruby -wT
- require 'dbi'
- DB_USERNAME = 'root'
- DB_PASSWORD = ''
- DBI.connect('DBI:Mysql:', DB_USERNAME, DB_PASSWORD) do |dbh|
- dbh.select_all('SHOW DATABASES') do |database,|
- next if %w[ information_schema mysql ].include?(database)
- dbh.select_all("SHOW TABLES FROM #{database}") do |table,|
- target = "#{database}.#{table}"
- puts "REPARING AND OPTIMIZING: #{target}"
- dbh.execute("REPAIR TABLE #{target}")
- dbh.execute("OPTIMIZE TABLE #{target}")
- end
- end
- end
Add Comment
Please, Sign In to add comment