Fix MySQL Lost Connection During Query Error - Skyvia

MySQL: Lost connection to MySQL server during query

Overview

The error Lost connection to MySQL server during query occurs when the connection between Skyvia and the MySQL server is dropped while a command is being executed. This typically happens when processing large datasets or when server-side timeout limits are too low.

Root Causes

  • The operation takes longer than the Command Timeout or Connection Timeout configured in Skyvia.
  • The MySQL server drops the connection due to net_read_timeout or net_write_timeout limits being exceeded.
  • The data packet size exceeds the max_allowed_packet limit on the MySQL server.

Resolution

Step 1: Increase timeout values in Skyvia

  1. Go to SkyviaConnections.
  2. Find and open your MySQL connection.
  3. Click Edit.
  4. Open Advanced Settings.
  5. Increase or set to 0 (no limit) the following parameters:
    • Command Timeout - maximum time in seconds for a single command to execute.
    • Connection Timeout - maximum time in seconds to establish a connection.
  6. Click Save and retry the integration.

Step 2: Adjust MySQL server parameters

If the issue persists, increase the following system variables on your MySQL server:

ParameterDescription
max_allowed_packetMaximum size of a single data packet. Increase if transferring large rows or BLOBs.
net_read_timeoutSeconds the server waits for data from the client before aborting the read.
net_write_timeoutSeconds the server waits to write a block to the client before aborting.

These can be set in your my.cnf / my.ini configuration file or applied dynamically:

SET GLOBAL max_allowed_packet = 67108864;
SET GLOBAL net_read_timeout = 3600;
SET GLOBAL net_write_timeout = 3600;