Bring the SQL files in the file into the database in order from highest to the next

Source: Internet
Author: User

############# 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.