Examples of max_allowed_packet parameter settings in MySQL

Source: Internet
Author: User

Today, developers in debugging Java programs, found that the MySQL reported the following questions:

Java.lang.IllegalArgumentException:Packet is larger than Max_allowed_packet from server configuration of 1048576 bytes

At Org.gjt.mm.mysql.Buffer.ensureCapacity (buffer.java:398)

At Org.gjt.mm.mysql.Buffer.writeBytesNoNull (buffer.java:386)

At Org.gjt.mm.mysql.PreparedStatement.executeUpdate (preparedstatement.java:352)

At Com.cicro.cws.database.DBManager.execute (dbmanager.java:450)

At Com.cicro.cws.publish.PreparePublish.saveSiteInstanceXmlIntoDB (preparepublish.java:827)

At Com.cicro.cws.publish.PreparePublish.generatePublishFiles (preparepublish.java:181)

At Com.cicro.cws.publish.PublishManager.publish (publishmanager.java:180)

At Com.cicro.cws.synchronize.InstanceSynchronize.publishSite (instancesynchronize.java:954)

At Com.cicro.cws.site.Site.publish (site.java:365)

At Com.cicro.cws.site.Site.run (site.java:338)

At Java.lang.Thread.run (thread.java:536)

Resolved as follows:

This problem is due to the fact that the imported SQL file is larger than the default Max_allowed_packet value of the system, and the workaround: for example, in MY.CNF modifications to: max_allowed_packet=32m #或者更高, Of course, you can add this parameter when the mysqld is started, but the variable must be loaded when the mysqld is restarted, so it must be restarted mysqld!

I loaded the Max_allowed_packet parameter into the MySQL startup file mysqld, and the Mysqld file section is set as follows:

${mysql}/bin/mysqld--user=mysql--datadir=${mysql}/data "$@" \

--language=${mysql}/share/mysql/english-o Max_connections=500-o wait_timeout=600 \

-O key_buffer=32m--max_allowed_packet=32m--port=${port}--socket=/tmp/mysql.sock &

Where the--max_allowed_packet=32m must have a front-sign.

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/database/MySQL/

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.