How to solve the large file import error in mysql

Source: Internet
Author: User

Today, we used the source command to import data, but the ERROR 2006 (HY000) at line ***: MySQL server has gone away ERROR occurred, according to the prompt, it seems that the size is limited. I will refer to the specific process below.

Use the source function to import large files through the command line.

Import Database

Common source commands

Go to the mysql Database Console,

For example, mysql-u root-p
 

Mysql> use Database

Then run the source command. The following parameter is the script file (for example,. SQL used here)

Mysql> source d: chai. SQL


But it is okay to import a small file. The following error occurs when importing a large file:

1. ERROR 2006 (HY000) at line ***: MySQL server has gone away
2. Got a packet bigger than 'max _ allowed_packet 'bytes or ERROR 1153 (08S01) at line 616: Got a packet bigger than 'max _ allowed_packet' by tes
3. sqlyog:
There was an error while executing a query.
The query and the error message has been logged:
C: UsersliangAppDataRoamingSQLyogsqlyog. err.

Please click on "Open Error File..." to open the error file.
 

The above problems are generally caused by the parameter configuration of my. ini or my. cnf.

The specific configuration method is as follows:

Note: add the following configuration under [mysqld:
The max_allowed_packet = 768 M parameter size is set by myself. I imported a file of M, and I started to use 64 M. Then I changed it to M.

After the configuration is modified:

Restart mysql
Net stop mysql disabled
Net start mysql startup

Go to mysql to check whether the operation is successful
Show variables like '% max_allowed_packet % ';

Shown as follows:
Max_allowed_packet | 805306368 indicates that the modification is successful.

Re-import. Haha import successful!


Some may encounter other problems.

An ERROR at line: Unknown command ''' may occur in the database character set. You only need to add the following command at the end to solve the problem.

-- Default-character-set = utf8

That is

Mysql-u username-p Password Database Name <SQL file path -- default-character-set = utf8

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.