In Windows, MySQL executes SQL script files in batches.

Source: Internet
Author: User

In Windows, MySQL executes SQL script files in batches recently for database migration. It is too difficult to manually execute MySQL script files in batches, so I wrote a script to share it. 01 @ echo off02: Specify the MySQL installation path 03D: 04cd D: \ MySQL Server 5.6 \ bin05: Database Name 06 @ set db = vp07 :: userName 08 @ set userName = root09: password 10 @ set password = root11: The SQL script to be executed 12 @ set sqlpath = E: \ 00. sql13: When you connect to the MySQL database and execute the SQL script-f script, if an error occurs, run -- default-character-set to specify the encoding of the imported data (the same as the database encoding) 14 mysql-f-u % userName % -- password = % password % db % <% sqlpath % -- default-character-set = gbk15: After the execution is complete, do not close dos window 16pause immediately. If you need to execute multiple script files 00. the SQL statement must be written in the following format: 1 source E: \ 01. sql2source E: \ 02. sql3source E: \ 03. sql4source E: \ 04. sql5source E: \ 05. SQL uses the source command to execute all scripts.

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.