1、创建基本表 testtb 2、执行shell脚本,创建testtb_0,testtb_1 ..... 分表 3、分库规则:db1库表为testtb_0,testtb_2..... db2库表为testtb_1,testtb_3..... #!bin/bash for i in `seq 0 999` do if [ $(($i%2)) == 0 ] then mysql -uuser -ppassword -hIP -P3306 -e "use db1;drop table if exists testtb_$i; create table testtb_$i like testtb ; " else mysql -uuser -ppassword -hIP -P3306 -e "use db2;drop table if exists testtb_$i; create table testtb_$i like testtb_; " -- 可以举一反三,如增加列,删除列,添加索引等 mysql -uuser -ppassword -hIP -P3306 -e "use db2;alter table testtb_$i add newcol numeric(20,0) default 0 ; " fi done