Interaction with mysql in shell scripts _ MySQL

Source: Internet
Author: User
Interaction with mysql in shell script bitsCN.com

Interaction with mysql in shell scripts

I:

[plain] mysqlCMD="mysql -h${MYSQL_HOST}  -P${MYSQL_PORT}  -u${MYSQL_USER} -p${MYSQL_PASS}"  create_table_sql="CREATE TABLE IF NOT EXISTS ${MYSQL_DB_NAME}.${access_table_name} (  id INT(10) NOT NULL AUTO_INCREMENT,  accId INT(10) NOT NULL,  URL INT(10) NOT NULL,  ....  PRIMARY KEY (id),  INDEX URL (URL)  )  COLLATE='utf8_general_ci'  ENGINE=MyISAM  ROW_FORMAT=DEFAULT  AUTO_INCREMENT=1"      empty_table_sql="TRUNCATE ${MYSQL_DB_NAME}.${table_name} "      echo $create_table_sql | ${mysqlCMD}  echo $empty_table_sql | ${mysqlCMD}  

Insert and other operations are the same

II:

[Plain] loadsql = "load data LOW_PRIORITY local infile '$ {LOG_TEMP}' into table $ {MYSQL_DB_NAME }. $ {table_name} fields terminated by '& 'lines terminated by'/N' (id, URL .....); "mysql-h $ {MYSQL_HOST}-P $ {MYSQL_PORT}-u $ {MYSQL_USER}-p' $ {MYSQL_PASS} '-N-e" $ {loadsql} "insert, etc. same operation

BitsCN.com

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.