51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

Linux下Mysql自动修复数据表脚本

Linux下Mysql自动修复数据表的脚本

#!/bin/bash
#This script used by repair tables
mysql_host=localhost
mysql_user=root
mysql_pass=root
database=test

tables = $(mysql -h $mysql_host -u $mysql_user -p $mysql_pass $database -A -Bse "show tables") for arg in $tables do check_status= $(mysql -h $mysql_host -u $mysql_user -p $mysql_pass $database -A -Bse "check table $arg" | awk '{ print $4 }') if [ "$check_status" = "OK" ] then echo "$arg is ok" else echo $(mysql -h $mysql_host -u $mysql_user -p $mysql_pass $database -A -Bse "repair table $arg") fi echo $(mysql -h $mysql_host -u $mysql_user -p $mysql_pass $database -A -Bse "optimize table $arg") done

标签: Mysql

赞(5)
未经允许不得转载:工具盒子 » Linux下Mysql自动修复数据表脚本