#!/bin/bash
host_name=127.0.0.1
user_name=
user_pwd=
database=
need_optmize_table=false
tables=$(/usr/local/webserver/mysql/bin/mysql-h$host_name-u$user_name-p$user_pwd$database-A-Bse"showtables")
fortable_namein$tables
do
check_result=$(/usr/local/webserver/mysql/bin/mysql-h$host_name-u$user_name-p$user_pwd$database-A-Bse"checktable$table_name"|awk'{print$4}')
if["$check_result"="OK"]
then
echo"It'snoneedtorepairtable$table_name"
else
echo$(/usr/local/webserver/mysql/bin/mysql-h$host_name-u$user_name-p$user_pwd$database-A-Bse"repairtable$table_name")
fi
#...,.....
if[$need_optmize_table=true]
then
echo$(/usr/local/webserver/mysql/bin/mysql-h$host_name-u$user_name-p$user_pwd$database-A-Bse"optimizetable$table_name")
fi
done