mysql 批量修复
更新时间:2016年05月03日 10:22:17 投稿:wulei
这篇文章主要介绍了mysql 批量修复,需要的朋友可以参考下
#!/bin/bash
host_name=127.0.0.1
user_name=
user_pwd=
database=
need_optmize_table=false
tables=$(/usr/local/webserver/mysql/bin/mysql -h$host_name -u$user_name -p$user_pwd $database -A -Bse "show tables")
for table_name in $tables
do
check_result=$(/usr/local/webserver/mysql/bin/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 $(/usr/local/webserver/mysql/bin/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 $(/usr/local/webserver/mysql/bin/mysql -h$host_name -u$user_name -p$user_pwd $database -A -Bse "optimize table $table_name")
fi
done
相关文章
Mysql 5.7.18 利用MySQL proxies_priv实现类似用户组管理
这篇文章主要为大家详细介绍了Mysql 5.7.18利用MySQL proxies_priv实现类似用户组管理,具有一定的参考价值,感兴趣的小伙伴们可以参考一下2017-07-07
Mysql实现Oracle中的Start with...Connect by方式
文章总结:作者在迁移数据库时,使用了Oracle的startwith进行树的递归查询,但遇到了一些问题,通过搜索和修改,作者成功地使用存储过程和预处理语句来实现动态查询,并解决了变量声明和预处理语句的问题2024-12-12


最新评论