mysql 批量修复

#!/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 "show tables")
for table_name in $tables
do
 check_result=$(/usr/local/webserver/MysqL/bin/MysqL -h$host_name -u$user_name -p$user_pwd $database -A -Bse "check table $table_name" | awk '{ print $4 }')
 if [ "$check_result" = "OK" ]
 then
 echo "It's no need to repair table $table_name"
 else
 echo $(/usr/local/webserver/MysqL/bin/MysqL -h$host_name -u$user_name -p$user_pwd $database -A -Bse "repair table $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 "optimize table $table_name")
 fi
done

相关文章

SELECT a.*,b.dp_name,c.pa_name,fm_name=(CASE WHEN a.fm_n...
if not exists(select name from syscolumns where name=&am...
select a.*,pano=a.pa_no,b.pa_name,f.dp_name,e.fw_state_n...
要在 SQL Server 2019 中设置定时自动重启,可以使用 Window...
您收到的错误消息表明数据库 'EastRiver' 的...
首先我需要查询出需要使用SQL Server Profiler跟踪的数据库标...