#!/bin/sh
#批量清空数据库表
user=root
password=fhData+123456
socket=/var/lib/mysql/mysql.sock
mycmd="mysql -u$user -p$password -S $socket"
for((i=0;i<=99;i++))
do
if [ $i -lt 10 ];then
#$i=("%02d\n",$i);
num=`echo $i | awk '{printf("%02d\n",$i)}'`;
#echo ${num};
$mycmd -e "use ai_user_pool;truncate TABLE ai_portrait_analyse_$num"
else
$mycmd -e "use ai_user_pool;truncate TABLE ai_portrait_analyse_$i "
fi
#$mycmd -e "use ai_user_pool;truncate TABLE ai_portrait_analyse_$i"
done
#!/bin/sh
#批量创建数据库
user=root
password=fhData+123456
socket=/var/lib/mysql/mysql.sock
mycmd="mysql -u$user -p$password -S $socket"
for((i=0;i<=99;i++))
do
if [ $i -lt 10 ];then
#$i=("%02d\n",$i);
num=`echo $i | awk '{printf("%02d\n",$i)}'`;
#echo ${num};
$mycmd -e "use ai_user_pool;CREATE TABLE ai_portrait_analyse_$num ( uid varchar(20) DEFAULT NULL COMMENT '用户id', tag_id bigint(20) DEFAULT NULL COMMENT '标签id', create_date datetime DEFAULT NULL COMMENT '行为日期', KEY portrait_tagid_uid (uid,tag_id) USING BTREE) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='标签统计表(新)';"
else
$mycmd -e "use ai_user_pool;CREATE TABLE ai_portrait_analyse_$i ( uid varchar(20) DEFAULT NULL COMMENT '用户id', tag_id bigint(20) DEFAULT NULL COMMENT '标签id', create_date datetime DEFAULT NULL COMMENT '行为日期', KEY portrait_tagid_uid (uid,tag_id) USING BTREE) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='标签统计表(新)';"
fi
done
同步数据
rsync -avz /var/lib/mysql 127.0.0.1:/var/lib/mysql