Software⏱️ 2 min read📅 2026-05-30

How to Fix ERROR 2006 Error – ERROR 2006 (HY000): MySQL server has gone away

MySQL server has gone away error when sourcing large SQL file.

Quick Answer: Check the MySQL query limit and increase it using the `set session variable` command, or consider using a more efficient method to import the data, such as using `LOAD DATA INFILE` instead of `SOURCE FILE`.

The 'ERROR 2006 (HY000): MySQL server has gone away' error occurs when the MySQL server disconnects unexpectedly, causing your application to fail. This issue can be caused by various factors such as a network connection problem, insufficient resources on the server, or an incorrect configuration.

⚠️ Common Causes

  • Network connection issues or a slow internet connection.
  • Inadequate resources on the MySQL server, such as insufficient RAM or CPU power.
  • Cached queries not being flushed properly.

✅ Best Solutions to Fix It

Method 1: Optimize Server Resources

  1. Step 1: Check the server's resource utilization to ensure it has enough RAM and CPU power.

Method 2: Flush Cached Queries

  1. Step 1: Run the command `FLUSH PRIVILEGES` and then `FLUSH TABLES FORCE` to clear cached queries.

💡 Conclusion

To resolve the 'ERROR 2006 (HY000): MySQL server has gone away' error, it is essential to identify and address the underlying cause. By optimizing server resources and flushing cached queries, you can prevent this issue from occurring in the future.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions