当前位置:Gxlcms > mysql > mysql批量修复

mysql批量修复

时间:2021-07-01 10:21:17 帮助过:33人阅读

#!/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

您可能感兴趣的文章:

  • 如何配置全世界最小的 MySQL 服务器
  • NoSQL 数据库你应该了解的 10 件事
  • 多种不同的 MySQL 的 SSL 配置
  • Ubuntu 14.04下安装和配置redis数据库
  • Ubuntu 14.04下安装MySQL
  • linux 下配置安装mysql以及配置【经验】

人气教程排行