mysql 批量修复
时间:2020-10-26 22:59:59|栏目: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
上一篇:20分钟MySQL基础入门
栏 目:Mysql
下一篇:详解MySQL 外键约束
本文标题:mysql 批量修复
本文地址:http://www.codeinn.net/misctech/15986.html