Packets larger than max_allowed_packet are not allowed

Source: Internet
Author: User
Tags mysql command line

The contents of a text file are typically imported into the database through MySQL's "Load data local infile" statement.
It's going to be fast, but today it's found that if the text is larger than 1M, an exception occurs: "Packets larger than max_allowed_packet are not allowed"

One of MySQL's system parameters: Max_allowed_packet, whose default value is 1048576 (1M),
Query: Show VARIABLES like '%max_allowed_packet% ';
Modify the value of this variable: "Max_allowed_packet = 1M" In the [Mysqld] section of the My.ini file in the MySQL installation directory, such as 4M (if there is no such line, add a line), save, and restart the MySQL service. You can now load more than 1M files.

MySQL Max_allowed_packet queries and modifications

Mysqlwindows

Depending on the profile, MySQL restricts the packet size that the server accepts.

Sometimes large inserts and updates are limited by max_allowed_packet parameters, resulting in failure.

View current configuration

Show VARIABLES like '%max_allowed_packet% ';

The results displayed are:

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

| variable_name | Value |

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

| Max_allowed_packet | 1048576 |

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

The above description is currently configured as: 1M

Modify method

1) Method 1

You can edit the my.cnf to modify (Windows My.ini), either in the [Mysqld] section or in the MySQL server configuration section.

Max_allowed_packet = 20M

If you can't find my.cnf, you can pass the

MySQL--help | grep my.cnf

To find my.cnf files.

2) Method 2

(very compromise, very tangled approach)

Access to MySQL server

Running on the MySQL command line

Set Global Max_allowed_packet = 2*1024*1024*10

Then shut down this MySQL server link and re-enter.

Show VARIABLES like '%max_allowed_packet% ';

See if Max_allowed_packet edits successfully

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.