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/