MySQL max_allowed_packet Query and modification

Source: Internet
Author: User

It is often necessary to import or export large SQL files in your work. It is generally OK to export, but in the import to other MySQL libraries, "Packet forquery is too large (1706 > 1024) may appear. You can change this value on the server by setting the Max_allowed_packet ' variable. "or the program (such as Python inside Executemany) appears"MySQL server has gone away"when inserting large amounts of data. These errors are probably MySQL MySQL max_allowed_packet default values are too small. Modify this value to generally swim in two different ways.

Method one: SQL statement modification

1. First log in to MySQL to see the current size of the value.

Show variables like '%max_allowed_packate% '

2, modify its size to 1G

Set Global Max_allowed_packet = 1024*1024*1024

This modification will require you to re-login to MySQL to see the modified values. And, this way modifies the MySQL max_allowed_packet, which may fail after MySQL restarts.

Mode two: My.ini modification

1. Add the following statement in the My.ini file. For example: Change to 1G. as shown. After the modification is complete, you will need to restart MySQL.

  


Note: In mode 2 max_allowed_packed must be added in "mysqld" to take effect.

MySQL Max_allowed_packet queries and modifications

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.