MySQL Import bulk SQL file data problem

Source: Internet
Author: User
Tags mysql import

The following two issues may occur in MySQL by importing a SQL file:

1. If the SQL file is too large, the "MySQL server has gone away" issue appears;

2. If the SQL file data is in Chinese, garbled characters will appear.

Solve the problem:

Issue 1: the MySQL server has gone away "issue occurs because the MySQL default" max_allowed_packet "variable value is too small.

View current configuration

Show VARIABLES like '%max_allowed_packet% ';

The results shown are:

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

| variable_name | Value |

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

| Max_allowed_packet | 1048576 |

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

Description The current configuration is: 1048576/1024/1024 = 1M

To modify the Max_allowed_packet value:

Method 1:set GLOBAL max_allowed_packet = 500*1024*1024; (Invalid test)

Method 2: Modify the configuration file directly and restart MySQL

Modify the My.ini file in Windows and modify the My.cnf file in Linux.

C:\Documents and Settings\All Users\Application Data\mysql\mysql Server 5.5\my.ini (when MySQL is installed, the specified data file directory)

After restarting MySQL, after viewing the modified Max_allowed_packet value

Issue 2: specify character set encoding at logon

mysql-uroot-p3308-p123456--default-character-set=utf8 (-p refers to the specified port number)

The final import is successful with the source command:

SOURCE E:ydj\test.sql

MySQL Import bulk SQL file data problem

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.