"Packet for query is too large" MySQL Error
Last modified by Eleni Cojocariu on 2026/09/10 20:35
Content
Explanation
Saving a large document or a large attachment fails, and the logs show:
Packet for query is too large (max_allowed_packet)The same limit also stops a fresh installation before anything visible goes wrong: XWiki starts without an error, but the import of the default set of pages fails part-way through.
Cause
MySQL refuses any single query larger than the size its max_allowed_packet variable allows, and XWiki stores a page's content and an attachment's data as single values. One large save is therefore one large query, and MySQL rejects it outright, what decides is the size of the individual document, not the size of the database.
The default value belongs to MySQL and has changed between versions, so read it from MySQL's manual page for the variable rather than assuming it.
Solution
- Open the MySQL server's configuration file. On Linux this is /etc/my.cnf. On Windows it is the my.ini file that the MySQL service names as its defaults file in its start-up arguments, which the service's own configuration shows.
- Raise max_allowed_packet in the server section, using a value larger than the biggest document or attachment you expect. 32M is a sensible starting point:
[mysqld] max_allowed_packet=32M - Restart the MySQL server so that it reads the new value.
- Retry what failed. The document or attachment is saved, and on a new installation the default set of pages imports to the end.