IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    mysql简单的碎片清理脚本

    阿川发表于 2017-04-11 13:50:00
    love 0

    #!/bin/bash 
    date=`date +"%Y-%m-%d %H:%M:%S"` 
    echo $date >>/root/information_schema.log 
    tables=$(/usr/local/mysql/bin/mysql -u root -p"tina" 2>/dev/null -e "select concat(table_schema,'.',table_name) from 
    information_schema.tables where data_free>0 and engine !='MEMORY';"
     |grep -v "concat" |grep -v "tinatest" |grep -v "information_schema" |grep -v "mysql") 
     
    for table in $tables 
    do 
      /usr/local/mysql/bin/mysql -u root-p"tina" 2>/dev/null -e "optimize no_write_to_binlog table $table;" >>/root/information_schema.log 
    done



沪ICP备19023445号-2号
友情链接