Mysql Workbench Export
In this tutorial, you'll learn about Fix MySQL Workbench Export. We cover key concepts, practical examples, and best practices.
You open MySQL Workbench, go to Data Export, select your database, and start the export. It runs for a while, then fails with "Error: Lost connection to MySQL server during query" β or completes but the dump file is only a few KB.
Wrong β
Data Export:
Export to Dump Project Folder
Tables: [all ticked]
β Include Create Database
β Dump Stored Procedures and Functions
β Dump Events
β Dump Triggers
Export runs for 2 minutes, then:
Error: 2013: Lost connection to MySQL server during query
The .sql file is 400 KB for what should be a 2 GB database.
You try again with Export to Self-Contained File β same error.
Right β
Increase timeouts in Workbench:
- Edit β Preferences β SQL Editor β DBMS connection read time out β set to
600(seconds) - Edit β Preferences β Administration β Export/Import:
- Max allowed packet:
256M - Read timeout:
600 - Write timeout:
600
- Max allowed packet:
Optimise export settings:
Export to Self-Contained File:
β Include Create Database
β Dump Stored Procedures and Functions
β Dump Events
β Dump Triggers
β Generate per-table DROP statements (optional)
β Create Packed File (.zip)
Advanced Options:
--max_allowed_packet=256M
--net_read_timeout=600
--net_write_timeout=600
--quick (avoid buffering all rows)
--single-transaction (for InnoDB consistency)
For extremely large exports (>10 GB):
Use mysqldump directly:
mysqldump -u root -p --single-transaction --quick --max_allowed_packet=256M \
mydb | gzip > /backups/mydb_$(date +%F).sql.gz
Progress indicator:
Dumping table users... 50,000 rows
Dumping table orders... 12,000 rows
Dumping table logs... 8,000,000 rows (this may take a while)
...
Process finished with exit code 0
File size: 1.2 GB compressed (up from 400 KB with the broken config).
Root Cause
Workbench's default net_read_timeout (30 s) is too low for large tables with millions of rows. MySQL abandons the connection midβexport. The small file is evidence the export stopped after the first few tables.
Prevention
- Always set Read timeout to at least 300 s for production exports.
- Use Export to Dump Project Folder (one file per table) β if one table fails, the rest are preserved.
- Schedule mysqldump via cron for routine backups instead of using the Workbench GUI.
- Monitor
max_allowed_packetβ exports fail silently when row data exceeds the limit.
Common Mistakes with workbench export
- Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors
- Non-exhaustive pattern matches that compile with warnings then crash at runtime
- Misunderstanding that
Stringis[Char]with poor performance for large text operations
These mistakes appear frequently in real-world MYSQL code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.
Practice Exercise
Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.
This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.
FAQ
Backup strategy is covered in detail in the DodaTech MySQL Administration course.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro