Home >Database >Mysql Tutorial >How Can I Prevent '2013. Lost connection to MySQL server during query' Errors in MySQL Workbench?
MySQL Workbench disconnection error solution
When working with large amounts of data in MySQL Workbench, it is crucial to maintain a persistent connection to the database to avoid interruptions and timeouts. An error often encountered during long operations is "2013. Lost connection to MySQL server during query." This article provides a solution to keep the connection active.
Solution
Step 1: Adjust the database management system connection timeout settings
In MySQL Workbench, click "Edit" -> "Preferences" -> "SQL Editor". In the Parameters section, find the DBMS connection read timeout (seconds) setting. By default, this setting may be lower, causing connections to fail prematurely.
Step 2: Set a higher value
To keep the connection active, increase the value of the "DBMS Connection Read Timeout (Seconds)" parameter. A reasonable value, such as 86400 (equivalent to 24 hours), will ensure that the connection remains active even during long queries.
Step 3: Restart MySQL Workbench
Close and reopen MySQL Workbench to apply changes.
Step 4: Terminate existing query
If any queries were running before, they may have timed out due to a lost connection. Terminate these queries using the Query menu -> Terminate option.
Step 5: Re-execute the query
Finally, re-perform the bulk insert operation to process the data again. The connection should now remain active throughout the process, eliminating the "2013" error.
The above is the detailed content of How Can I Prevent '2013. Lost connection to MySQL server during query' Errors in MySQL Workbench?. For more information, please follow other related articles on the PHP Chinese website!