Documentation Home
MySQL Workbench Manual
Related Documentation Download this Manual
PDF (US Ltr) - 14.9Mb
PDF (A4) - 14.9Mb
HTML Download (TGZ) - 13.0Mb
HTML Download (Zip) - 13.0Mb

MySQL Workbench Manual  /  ...  /  Reverse Engineering Using a Create Script Reverse Engineering Using a Create Script

To reverse engineer using a create script, choose the File, Import, Reverse Engineer MySQL Create Script... menu item for a model.

Tables, views, routines, routine groups, indexes, keys, and constraints can be imported from an SQL script file. Objects imported using an SQL script can be manipulated within MySQL Workbench the same as other objects.

Figure 9.40 Reverse Engineer SQL Script: Input

Reverse Engineer SQL Script: Input

  • Select SQL script file: Open a file open dialog box with the default file type set to an SQL script file, a file with the extension sql.

  • File encoding: Defaults to UTF8.

  • Place imported objects on a diagram: Also create an EER diagram in MySQL Workbench.


    Importing a large number (1000) objects could fail to create an EER diagram and instead emit a resource warning with the text "Too many objects are selected for auto placement. Select fewer elements to create the EER diagram." In this case, execute the reverse engineering wizard with this option disabled, manually create the EER diagram, and then import the 1000+ objects using the EER diagram catalog viewer.

If your script creates a database, MySQL Workbench creates a new physical schemata tab on the MySQL Model page.

Click Execute to reverse engineer the SQL script, verify its results, and optionally place the objects in a new EER diagram.

Figure 9.41 Reverse Engineer SQL Script: Execution

Reverse Engineer SQL Script: Execution

Click Next to view a summary of the results, and then Finish to close the wizard.

Figure 9.42 Reverse Engineer SQL Script: Results

Reverse Engineer SQL Script: Results

Before exiting MySQL Workbench, be sure to save the schema. Choose the File, Save menu item and the reverse-engineered database will be saved as a MySQL Workbench file with the extension mwb.

See Section 9.3.3, “Importing a Data Definition SQL Script”, for a tutorial on reverse engineering the sakila database.

Creating a DDL script

You can create a data definition (DDL) script by executing the mysqldump db_name --no-data > script_file.sql command. Using the --no-data option ensures that the script contains only DDL statements. However, if you are working with a script that also contains DML statements you need not remove them; they will be ignored.


If you plan to redesign a database within MySQL Workbench and then export the changes, be sure to retain a copy of the original DDL script. You will need the original script to create an ALTER script. For more information, see Section, “Altering a Schema”.

Use the --databases option with mysqldump if you wish to create the database as well as all its objects. If there is no CREATE DATABASE db_name statement in your script file, you must import the database objects into an existing schema or, if there is no schema, a new unnamed schema is created.

User Comments
  Posted by Rony Bassoul on July 28, 2016
The 'Import - Reverse Engineer MySQL Create Script...' cannot be seen in the Home Tab main menu, it can be found under File in tabs like MySQL Model or EER Diagram only when those are opened.
So in case that Workbench is freshly opened, it can be found under the Models section at the bottom, by clicking on > 'Create EER Model from Script'.
Sign Up Login You must be logged in to post a comment.