cat createdbtable.sh#!/bin/bash#-------------------------------------------------- #Created : 2015-05-26#author:jimmygong#mail:[email protected] #Function: #Version: 1.0#------------------------------- -------------------mysqluser= "MySQL" mysqlpass= "Redhat" mysqlport= "3306" alldatabases= (AAA&NBSP;BBB&NBSP;CCC &NBSP;DDD&NBSP;EEE&NBSP;FFF&NBSP;GGG&NBSP;HHH&NBSP;III&NBSP;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&nbSp 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) "; done ) & done wait}createdbtable "10.0.0.104" createdbtable "10.0.0.105" Exit 0
This article is from the "7928217" blog, please be sure to keep this source http://7938217.blog.51cto.com/7928217/1655465
Shell scripts build multiple libraries, multiple tables, multiple instances