Welcome

首页 / 数据库 / MySQL / 修复mysql表的脚本

修复mysql表的脚本2013-04-14
#!/bin/bash#author:itnihao#mail:itnihao@qq.com#date 2013-02-18#version v1.0#function:repair mysql tableUser=rootPassword=123456Host=192.168.1.10Database=$(mysql -u${User} -p${Password} -h${Host}-e "show databases"|grep -v"Database")for DBname in ${Database} do table=$(mysql -u${User} -p${Password} -h${Host} ${DBname} -e "show tables"|grep -v tables_in_mysql)for tableName in ${table}domysql -u${User} -p${Password} -h${Host} ${DBname} -e "check table ${tableName}" [ "$?" != 0 ] &&mysql -u${User} -p${Password} -h${Host} ${DBname} -e "repair table ${tableName}"donedone