1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#!/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
|
相关文章
- Mysql5.7自定义函数递归报错1424 Recursive stored functions and triggers are not allowed
- 有关使用phpstudy搭建sqli-lab环境搭建时发生Uncaught Error: Call to undefined function mysql_connect()错误
- mysql if()
- mysql错误一例:ERROR 1030 (HY000): Got error 28 from storage engine
- MySQL搜索:WHERE
- 批量生成随机字符串并保存到excel
- mysql搜索不区分大小写
- PHP MySQL Insert Into
- mysql limit 性能问题分析
- MySQL服务相关