To generate a script from a diagram in MySQL Workbench:

  1. Select File > Export > Forward Engineer SQL CREATE Script...
  2. Enter a location to save the file (optional) and set options to include on the script (such as DROP statements etc), then click Continue
  3. Exclude any objects by deselecting them, otherwise leave them as is, then click Continue
  4. The script is generated. You can copy it to your clipboard or click Finish to save it to a file

Below are screenshots for the above steps.

Start the Process

Select File > Export > Forward Engineer SQL CREATE Script...:

Screenshot of the Export option for Forward Engineer SQL CREATE Script...

Using the “Export” option to generate an SQL script.

SQL Export Options

Enter a location to save the file (optional) and set options to include on the script (such as DROP statements etc), then click Continue:

Screenshot of the SQL Export Options dialog box

The “SQL Export Options” dialog box allows you to make adjustments to your script.

SQL Object Export Filter

Exclude any objects by deselecting them, otherwise leave them as is, then click Continue:

Screenshot of the SQL Object Export Filter dialog box

The “SQL Object Export Filter” dialog box allows you to exclude certain options from the script if required.

The Script

The script is generated. You can copy it to your clipboard or click Finish to save it to a file:

Screenshot of the Review Generated Script dialog box

The “Review Generated Script” dialog box allows you to copy the script to your clipboard, and/or save it (by clicking “Finish”).