首页 > 数据库 > MySQL > 正文

mysql 批量修复

2024-07-24 13:09:18
字体:
来源:转载
供稿:网友
这篇文章主要介绍了mysql 批量修复,需要的朋友可以参考下
 
#!/bin/bashhost_name=127.0.0.1user_name=user_pwd=database=need_optmize_table=falsetables=$(/usr/local/webserver/mysql/bin/mysql -h$host_name -u$user_name -p$user_pwd $database -A -Bse "show tables")for table_name in $tablesdo 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") fidone


注:相关教程知识阅读请移步到MYSQL教程频道。
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表