Skip to content

Mysql Workbench Export

DodaTech 3 min read

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.

Increase timeouts in Workbench:

  1. Edit β†’ Preferences β†’ SQL Editor β†’ DBMS connection read time out β†’ set to 600 (seconds)
  2. Edit β†’ Preferences β†’ Administration β†’ Export/Import:
    • Max allowed packet: 256M
    • Read timeout: 600
    • Write timeout: 600

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

  1. Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors
  2. Non-exhaustive pattern matches that compile with warnings then crash at runtime
  3. Misunderstanding that String is [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

**Q: Should I use Dump Project Folder or Self-Contained File?**

A: Dump Project Folder for large exports β€” easier to debug failures per table. Self-Contained for CI/CD pipelines.

**Q: Why does my export include `DEFINER` statements that break on import?**

A: This is a mysqldump default. Add --skip-definer in Advanced Options.

**Q: Can I export only specific rows (WHERE clause)?**

A: Yes β€” in Data Export, tick Where and enter id > 1000. Applies to all selected tables.

**Q: Is there a way to see export progress?**

A: Workbench shows a progress bar per table in the Export tab. For mysqldump, use pv to pipe through and monitor.


Backup strategy is covered in detail in the DodaTech MySQL Administration course.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro