############# Demand #############
Sequentially from top to bottom, each line of SQL file inside the file is directed into the database
############# Execution Method #############
SH import_ku.sh variable 1 variable 2 variable 3
Variable 1: File that stores the database script file name
Variable 2: Database user name
Variable 3: Database password
Code Show
#!/bin/bashoutput= "Echo-e" tails= "\033[0m" green= "\033[32m" red= "\033[31m" flicker= "\033[05m" DATA= ' cat $ | wc-l ' for ( (i=1;i<= $DATA; i++)) Do sql= ' head-$i $ | Tail-1 ' mysql-u$2-p$3 < $SQL nu=$? If [$NU-eq 0];then $OUTPUT $GREEN "$SQL exculde Success" $TAILS echo else $OUTPUT $RED $flicker "$SQL Exculde eroor!" $TAILS Echo Fidone
Execution results show
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M01/8B/42/wKiom1hIDs2z7Lk5AACRzAAAQ7Q846.png-wh_500x0-wm_3 -wmp_4-s_4179331181.png "title=" 1.png "alt=" Wkiom1hids2z7lk5aacrzaaaq7q846.png-wh_50 "/>
This article is from the "Wsyht90 blog" blog, make sure to keep this source http://wsyht90.blog.51cto.com/9014030/1880502
Bring the SQL files in the file into the database in order from highest to the next