#!/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数据库的高可用方案总结
高可用架构对于互联网服务基本是标配,无论是应用服务还是数据库服务都需要做到高可用。虽然互联网服务号称7*24小时不间断服务,但多多少少有一
逐步讲解MySQL中定时事件计划的创建
一、使用过程1.查看当前是否已开启事件计划(调度器)有3种方法:SHOWVARIABLESLIKE'event_scheduler';SELECT@@event_scheduler;SHOWPROCESSLIST;2.开启事件计划(调度器)
MYSQL使用正则表达式过滤数据
一、正则与LIKE的区别Mysql的正则表达式仅仅使SQL语言的一个子集,可以匹配基本的字符、字符串。例如:select*fromwp_postswherepost_nameREGEXP'hello',可以检索