Immediate Fix
To stop MySQL from dropping connections over WiFi, you must first increase the server-side timeout variables. Wireless networks often experience micro-stuttering that causes the server to close “idle” connections prematurely.
Run the following commands in your MySQL console to extend the timeout windows:
SET GLOBAL wait_timeout = 28800;
SET GLOBAL interactive_timeout = 28800;
SET GLOBAL net_read_timeout = 60;
SET GLOBAL net_write_timeout = 60;
Additionally, disable power saving on your wireless network interface. On Linux, this prevents the WiFi card from entering a low-power state that interrupts the TCP stream.
sudo iwconfig wlan0 power off
Technical Explanation
MySQL relies on stable TCP/IP connections. Unlike wired Ethernet, WiFi is a half-duplex medium susceptible to electromagnetic interference and packet collision. When a packet is lost, the TCP window may shrink, leading to a delay that exceeds the MySQL net_read_timeout.
The table below highlights why wireless environments trigger these specific MySQL errors:
| Issue | Impact on MySQL | Resulting Error |
|---|---|---|
| Signal Jitter | Varied packet arrival times | Connection Timeout |
| Power Management | WiFi card goes to sleep during idle queries | MySQL server has gone away |
| Packet Loss | Broken TCP handshake | Lost connection during query |

The Keep-Alive Factor
By default, MySQL may not send keep-alive packets frequently enough. When the WiFi signal fluctuates, the router might drop the session from its NAT table, leaving the client and server unable to communicate even though the software thinks the connection is open.
Alternative Methods
If adjusting timeouts does not solve the issue, consider using an SSH tunnel. SSH tunnels are more resilient to intermittent connectivity because they can be configured to keep the session alive independently of the MySQL protocol.
ssh -L 3307:127.0.0.1:3306 user@remote-db-server -N
Another effective method is implementing connection pooling at the application level. Using a pooler like HikariCP or the built-in MySQL Workbench “Keep-Alive” feature ensures that the application automatically reconnects if the WiFi signal drops momentarily.
Finally, check your “max_allowed_packet” size. If your WiFi connection is weak, sending very large packets can lead to fragmentation and failure. Setting this to a higher value like 64M can sometimes prevent drops during large data transfers.