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

Ubuntu下定时提交代码到SVN服务器的Shell脚本分享

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

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

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

linux shell实现守护进程脚本

用来检测输入的选项$1是否在PATH中的shell脚本

CentOS下mysql定时备份Shell脚本分享

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

一个监控LINUX目录和文件变化的Shell脚本分享

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

精品推荐
分类导航