Guest User

Untitled

a guest
Mar 13th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #!/usr/bin/ruby -wT
  2.  
  3. require 'dbi'
  4.  
  5. DB_USERNAME = 'root'
  6. DB_PASSWORD = ''
  7.  
  8. DBI.connect('DBI:Mysql:', DB_USERNAME, DB_PASSWORD) do |dbh|
  9. dbh.select_all('SHOW DATABASES') do |database,|
  10. next if %w[ information_schema mysql ].include?(database)
  11. dbh.select_all("SHOW TABLES FROM #{database}") do |table,|
  12. target = "#{database}.#{table}"
  13. puts "REPARING AND OPTIMIZING: #{target}"
  14. dbh.execute("REPAIR TABLE #{target}")
  15. dbh.execute("OPTIMIZE TABLE #{target}")
  16. end
  17. end
  18. end
Add Comment
Please, Sign In to add comment