Wiki source code of "Packet for query is too large" MySQL Error
Last modified by superadmin on 2026/11/25 21:31
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | Saving a large document or a large attachment fails, and the logs show: | ||
| 2 | |||
| 3 | {{code language="none"}} | ||
| 4 | Packet for query is too large (max_allowed_packet) | ||
| 5 | {{/code}} | ||
| 6 | |||
| 7 | 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. | ||
| 8 | |||
| 9 | === Cause === | ||
| 10 | |||
| 11 | 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. | ||
| 12 | |||
| 13 | The default value belongs to MySQL and has changed between versions, so read it from [[MySQL's manual page for the variable>>https://dev.mysql.com/doc/refman/8.4/en/max-allowed-packet.html]] rather than assuming it. | ||
| 14 | |||
| 15 | === Solution === | ||
| 16 | |||
| 17 | 1. 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. | ||
| 18 | 1. 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:((( | ||
| 19 | {{code language="ini"}} | ||
| 20 | [mysqld] | ||
| 21 | max_allowed_packet=32M | ||
| 22 | {{/code}} | ||
| 23 | ))) | ||
| 24 | 1. Restart the MySQL server so that it reads the new value. | ||
| 25 | 1. Retry what failed. The document or attachment is saved, and on a new installation the default set of pages imports to the end. |