45fan.com - 路饭网

搜索: 您的位置主页 > 网络频道 > 阅读资讯:如何批量修复mysql?

如何批量修复mysql?

2016-06-13 06:03:44 来源:www.45fan.com 【

如何批量修复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

本文地址:http://www.45fan.com/a/question/53277.html
Tags: mysql 批量 修复
编辑:路饭网
关于我们 | 联系我们 | 友情链接 | 网站地图 | Sitemap | App | 返回顶部