use strict; use DBI; my ($results, $subresults, $subresults1, $ref,$ref1,$ref2,$subref,$subref1) = undef; my @queries; my $dbh = DBI->connect("DBI:mysql:;host=127.0.0.1:3306",'root','fbg4ips') or die $DBI::errstr; $results = $dbh->prepare("show databases;") or die $dbh->errstr(); $results->execute() or die $results->errstr(); my $count = 1; while ($ref = $results->fetchrow_hashref()) { my $db = $ref->{'Database'}; print $db; print "\n"; $subresults = $dbh->prepare("show tables from $ref->{'Database'};") or die $dbh->errstr(); $subresults->execute() or die $subresults->errstr(); while ($subref = $subresults->fetchrow_hashref()) { my $table_name = $subref->{'Tables_in_'.$ref->{'Database'}}; print "--> "; print $table_name; if ($db !~ /mysql/i and $db !~ /information_schema/) { push @queries, "repair table $db.$table_name extended use_frm;" } print "\n"; } } foreach (@queries) { $results = $dbh->prepare($_) or die $dbh->errstr(); $results->execute() or die $results->errstr(); print "Executed -> $_\n"; }