// mysql · connections

max_allowed_packet

Largest single packet, and so the largest row, BLOB or statement, the server accepts.

默认
64MB
Range
1KB to 1GB
Restart needed
否
Default checked on
MySQL 8.4 LTS

作用

Also limits the size of strings that functions such as GROUP_CONCAT or REPEAT can return. The client has its own max_allowed_packet; both must be large enough.

默认值

64MB. 67108864 bytes since MySQL 8.0 (MySQL 8.4).

Check the current value

SHOW GLOBAL VARIABLES LIKE 'max_allowed_packet';

SELECT VARIABLE_NAME, VARIABLE_SOURCE, MIN_VALUE, MAX_VALUE, SET_TIME
FROM performance_schema.variables_info
WHERE VARIABLE_NAME = 'max_allowed_packet';

Change it

SET GLOBAL max_allowed_packet = 268435456;    -- until the next restart
SET PERSIST max_allowed_packet = 268435456;   -- now and after restarts

No restart. SET GLOBAL or SET PERSIST takes effect immediately; SET PERSIST also writes mysqld-auto.cnf so the value survives restarts.

When to change it

When inserts of large BLOBs or long multi-row INSERTs fail with 'Packet too large' or the connection drops on big dumps.

What can go wrong

The session value is read-only and taken from the global one when a connection opens. Large values let a client make the server allocate big buffers.

Questions about max_allowed_packet

What is the default value of max_allowed_packet in MySQL?

64MB. 67108864 bytes since MySQL 8.0 (MySQL 8.4).

Does changing max_allowed_packet require a restart?

No. No restart. SET GLOBAL or SET PERSIST takes effect immediately; SET PERSIST also writes mysqld-auto.cnf so the value survives restarts.

When should I change max_allowed_packet?

When inserts of large BLOBs or long multi-row INSERTs fail with 'Packet too large' or the connection drops on big dumps.

Back to all MySQL settings, or check the MySQL manual for every option.

// one client for every engine

Check max_allowed_packet on your own server

SQLly runs the query above against MySQL and the other engines in this reference, from one desktop app on macOS, Windows and Linux.