1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
我的博客已迁移到xdoujiang.com请去那边和我交流
cat
createdbtable.sh
#!/bin/bash
#--------------------------------------------------
#Created:2015-05-26
#Author:jimmygong
#Mail:jimmygong@taomee.com
#Function:
#Version:1.0
#--------------------------------------------------
mysqluser=
"mysql"
mysqlpass=
"redhat"
mysqlport=
"3306"
alldatabases=(aaa bbb ccc ddd eee fff ggg hhh iii jjj)
alltables=(t1 t2 t3 t4 t5 t6 t7 t8 t9 t10)
function
mysqlconn ()
{
mysqlip=$1
comm
=$2
mysql -u${mysqluser} -p${mysqlpass} -h${mysqlip} -P${mysqlport} -e
"$comm"
|
sed
1d
}
function
createdbtable ()
{
for
((j=0;j<${
#alldatabases[*]};j++))
do
(
mysqlconn $1
"CREATE DATABASE IF NOT EXISTS ${alldatabases[$j]}"
;
for
((k=0;k<${
#alltables[*]};k++))
do
mysqlconn $1
"use ${alldatabases[$j]};CREATE TABLE ${alltables[$k]} (id int not null,name char(20))"
;
done
)&
done
wait
}
createdbtable
"10.0.0.104"
createdbtable
"10.0.0.105"
exit
0
|
本文转自 xdoujiang 51CTO博客,原文链接:http://blog.51cto.com/7938217/1655465,如需转载请自行联系原作者