手机
当前位置:查字典教程网 >脚本专栏 >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脚本】相关文章:

提取oralce当天的alert log的shell脚本代码

5个实用的shell脚本面试题和答案

实现批量linux格式化硬盘和挂载硬盘脚本分享

linux下实现ftp自动备份shell脚本

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

expect实现批量修改linux密码脚本分享

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

linux 监视端口是否正常的shell脚本

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

自动杀掉占用较多CPU资源的Shell脚本

精品推荐
分类导航