手机
当前位置:查字典教程网 >脚本专栏 >linuxshell >实现MySQL定时批量检查表repair和优化表optimize table的shell脚本
实现MySQL定时批量检查表repair和优化表optimize table的shell脚本
摘要:本文介绍mysql定时批量检查表repair和优化表optimizetable的shell脚本,对于MySQL数据库的定期维护相当有用!如下...

本文介绍mysql定时批量检查表repair和优化表optimize table的shell脚本,对于MySQL数据库的定期维护相当有用!如下所示:

#!/bin/bash host_name=192.168.0.123 user_name=jincon.com user_pwd=jincon.com database=my_db_name need_optmize_table=true tables=$(mysql -h$host_name -u$user_name -p$user_pwd $database -A -Bse "show tables") for table_name in $tables do check_result=$(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 $(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 $(mysql -h$host_name -u$user_name -p$user_pwd $database -A -Bse "optimize table $table_name") fi done

【实现MySQL定时批量检查表repair和优化表optimize table的shell脚本】相关文章:

查找目录下同名但不同后缀名文件的shell脚本代码

分享个简易版Linux服务器初始化Shell脚本

自动重启服务的shell脚本代码

大小写字母转换的shell脚本代码

8个实用的Shell脚本分享

获取同一网段下所有机器MAC地址的shell脚本

消耗CPU资源的shell脚本

判断文件是否存在的shell脚本代码

后台实时分流文件的shell脚本

验证用户输入的参数合法性的shell脚本

精品推荐
分类导航