Skip to content

Fix MySQL Workbench Model Sync – Forward Engineer Fails

DodaTech Updated 2026-06-24 3 min read

In this tutorial, you'll learn about Fix MySQL Workbench Model Sync. We cover key concepts, practical examples, and best practices.

You design an ERD in MySQL Workbench, run Forward Engineer, and get errors — or the generated SQL is syntactically wrong. Tables are missing indexes, columns have wrong types, or the script fails halfway.

Wrong ❌

You create a model with a simple users table:

users
├── id (INT, PK, AI)
├── email (VARCHAR(255), UNIQUE, NN)
├── status (ENUM('active','inactive'))

Click Database → Forward Engineer → accept defaults → Execute.

Error output:

ERROR 1064: You have an error in your SQL syntax
... near 'status ENUM('active','inactive') NOT NULL'

The generated SQL has:

CREATE TABLE `users` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `email` VARCHAR(255) NOT NULL,
  `status` ENUM('active','inactive'),
  PRIMARY KEY (`id`),
  UNIQUE INDEX `email_UNIQUE` (`email`) VISIBLE
);

The ENUM definition is fine, but if the target MySQL version is < 5.7, VISIBLE is unknown.

Set the correct MySQL version in the model:

  1. Model → Model Options → MySQL Version
  2. Pick the exact version on the target server (e.g. 8.0.33)
  3. Click OK

Also in Forward Engineer wizard:

  1. Database → Forward Engineer
  2. Options tab:
    • Generate DROP statements before each CREATE
    • Omit schema qualifiers (keep unless cross‑schema)
    • SQL compatibility mode: tick only what you need
  3. Select Objects — verify all tables, views, and routines are checked
  4. Review SQL — the preview pane now shows version‑compatible syntax:
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;

CREATE TABLE `users` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `email` VARCHAR(255) NOT NULL,
  `status` ENUM('active','inactive') NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE INDEX `email_UNIQUE` (`email`)
) ENGINE = InnoDB;

SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;

Click Execute → ✅ Script runs clean.

Root Cause

Workbench generates DDL optimised for the MySQL version set in the model. If the version is wrong (e.g. default 5.6 when target is 8.0, or vice versa), syntax like VISIBLE, INVISIBLE, ALGORITHM, or LOCK clauses may be incompatible.

Prevention

  • Set the MySQL Version in model options before drawing the first table.
  • Use Synchronize Model instead of Forward Engineer for incremental changes — it compares live schema vs model.
  • Run Forward Engineer to a SQL script file first, then review before executing against production.
  • Store the model .mwb file in version control alongside migration scripts.

Common Mistakes with workbench model sync

  1. Placing the wildcard pattern first in case expressions, making all subsequent patterns unreachable
  2. Using head and tail instead of pattern matching, causing runtime errors on empty lists
  3. Forgetting that lazy evaluation defers computation until the value is forced, causing space leaks with unevaluated thunks

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: Can I sync only selected tables?**

A: Yes — in Forward Engineer → Select Objects, uncheck tables you don't want to sync.

**Q: What if the target already has data?**

A: Use Synchronize Model with Alter Table (safe) instead of CREATE TABLE (destructive). Workbench can generate ALTER TABLE statements.

**Q: Does model sync preserve data?**

A: Forward Engineer drops and recreates tables. For data‑preserving changes, use Synchronize Model with Use ALTER TABLE.

**Q: How do I see the full SQL before executing?**

A: In the Review SQL step, scroll through every statement. Save to a file with Save to File button.


ERD modelling with Workbench is covered in the DodaTech MySQL Data Modeling course.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro