Execute MySQL script file under Windows batch processing

Source: Internet
Author: User

Reprint to http://my.oschina.net/u/660932/blog/117929

One

@echo off
Setlocal enabledelayedexpansion
:: Coder by Mark_li Powerd by IBAT 1.6
CD "C:\Program files\mysql\mysql Server 5.5\bin"
:: Database name
@set db=hrms
:: User Name
@set Username=root
:: Password
@set password=
:: SQL Script to execute
@set sqlpath= "C:\Program files\mysql\mysql Server 5.5\test_hrms.sql"
:: Connection to MySQL database and execute SQL script-F script execution, error continues execution--default-character-set Specifies the encoding of the imported data (same as database encoding)
Mysql-f-u%userName%--password=%password%%db% <%sqlpath%--DEFAULT-CHARACTER-SET=GBK
:: Do not close the DOS window immediately after execution is complete

Pause

Second, set the timeout command

Add under My.ini file

wait_timeout=2880000
Interactive_timeout = 2880000
Max_allowed_packet = 100M

Third, if you want to execute multiple SQL scripts

Replace Test_hrms.sql with source "C:\Program Files\mysql\mysql server 5.5\test_hrms.sql" "C:\Program files\mysql\mysql Server 5.5\test_hrms2.sql "

"C:\Program files\mysql\mysql Server 5.5\test_hrms3.sql"

Execute MySQL script file under Windows batch processing

Related Article

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.