Repair All MySQL Tables

Premise

This is a simple script to run repair operations on all MySQL tables. Very useful if your MySQL server crashes or your MySQL data partition fills up.

#!/bin/bash
for db in `mysql -s -B -e "show databases"`;
do      
       for table in `mysql $db -s -B -e "show tables"`;
       do      
               mysql $db -e "repair table $table";
       done
done

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>