How to import large-capacity SQL file data from MySQL

Source: Internet
Author: User
MySQL imports large SQL file data. 1. If the SQL file is too large, quot; MySQLserverhasgoneawayquot; may occur. 2. If the SQL file data is in progress.

MySQL imports large-capacity SQL file data. 1. If the SQL file is too large, the following error occurs: quot; MySQL server has gone awayquot; 2. If the SQL file data is in progress.

Mysql may encounter the following two problems when importing SQL files:

1.IfSQLThe file is too large.,Will appear"MySQL server has gone away"Problem;

2.IfSQLFile data has Chinese Characters,Garbled


Question 1:AppearsMySQL server has gone away"Problem,BecauseMysqlDefault"Max_allowed_packet"Variable value too small.

View current configuration

Show VARIABLES like '% max_allowed_packet % ';

The result is as follows:

+ -------------------- + --------- +

| Variable_name | Value |

+ -------------------- + --------- +

| Max_allowed_packet| 1048576 |

+ -------------------- + --------- +

The current configuration is as follows:1048576/1024/1024 = 1 M


Method1: set global max_allowed_packet = 500*1024*1024 ;(Tested invalid)

Method2:Directly modify the configuration file,RestartMysql

WindowsMediumModifyMy. iniFile, in LInuxModifyingMy. cnfFile.

C: \ Documents ents and Settings \ All Users \ Application Data \ MySQL Server 5.5 \ my. ini (InstallMysqlTime,Specified data file directory)

Question 2:Specify character set encoding when logging on

Mysql-uroot-P3308-p123456--default-character-set = utf8 (-PIndicates the specified port number.)

FinallySourceCommand to import successfully:

Source E: ydj \ test. SQL

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: 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.