// mysql · timeouts

net_read_timeout

Seconds the server waits for more data from a client before aborting the read.

預設
30
Range
1 to 31536000 seconds
Restart needed
否
Default checked on
MySQL 8.4 LTS

其作用

It applies whenever the server is reading from the client: a statement arriving in several packets, or the data behind a LOAD DATA LOCAL. If the next block does not arrive within the limit the connection is dropped, which clients report as 'Lost connection to MySQL server during query'.

預設值

30. 30 seconds (MySQL 8.4).

Check the current value

SHOW GLOBAL VARIABLES LIKE 'net_read_timeout';

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

Change it

SET SESSION net_read_timeout = 600;   -- this connection
SET GLOBAL net_read_timeout = 600;    -- new connections, until restart
SET PERSIST net_read_timeout = 600;   -- new connections, and after restarts

No restart. SET GLOBAL (or SET PERSIST, which also survives restarts) applies to connections opened afterwards; existing connections keep their session value unless they SET it themselves.

When to change it

When a bulk loader or a client on a slow link sends very large statements in pieces and connections keep dying mid-send.

What can go wrong

Raising it globally keeps half-dead connections, each with a thread and its buffers, alive for the whole limit. A value that has to be huge usually points at a network problem or a client writing data in dribbles; find that instead of stretching the timeout for everyone.

Questions about net_read_timeout

What is the default value of net_read_timeout in MySQL?

30. 30 seconds (MySQL 8.4).

Does changing net_read_timeout require a restart?

No. No restart. SET GLOBAL (or SET PERSIST, which also survives restarts) applies to connections opened afterwards; existing connections keep their session value unless they SET it themselves.

When should I change net_read_timeout?

When a bulk loader or a client on a slow link sends very large statements in pieces and connections keep dying mid-send.

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

// one client for every engine

Check net_read_timeout 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.

本頁文字與資料: CC BY 4.0,請註明出處 SQLly (sqlly.app)。 程式碼與 SQL 片段: MIT. 授權詳情