Documentation Home
MySQL Workbench Manual
Related Documentation Download this Manual
PDF (US Ltr) - 16.3Mb
PDF (A4) - 16.3Mb
HTML Download (TGZ) - 14.6Mb
HTML Download (Zip) - 14.7Mb

MySQL Workbench Manual  /  ...  /  Reverse Engineering a Live Database Reverse Engineering a Live Database

To reverse-engineer a live database, click Database and then Reverse Engineer from the menu. The figure that follows shows an example of the Reverse Engineer Database wizard.

Figure 9.43 Reverse Engineer Database Wizard

Content is described in the surrounding text.

The first step of the wizard enables you to set up a connection to the live database you intend to reverse-engineer. You can set up a new connection or select a previously created stored connection. Typical information required for the connection includes host name, user name and password.

After this information has been entered, or you have selected a stored connection, click the Next button to proceed to the next step (shown in the figure that follows).

Figure 9.44 Connect to DBMS

Content is described in the surrounding text.

Review the displayed information to make sure that the connection did not generate errors, then click Next.

The next step displays the schemas available on the server. Select the check box of each schemas you intend to process. In the following figure, the world schema is selected.

Figure 9.45 Select Schemas

Content is described in the surrounding text.

After you have selected the desired schemas, click the Next button to continue.

The wizard then displays the tasks it carried out and summarizes the results of the operation.

Figure 9.46 Retrieve Objects

Content is described in the surrounding text.

Review the results before clicking Next to continue.

The next step opens the Select Objects page. It has a section for each object type present in the schema (tables, views, routines, and so forth). This step is of special interest if you do not intend to import all the objects from the existing database. It gives you the option of filtering which objects are imported. Each section has a Show Filter button. Click this button if you do not want to import all the objects of a specific type. The following figure shows an example with the filter open.

Figure 9.47 Select Objects

Content is described in the surrounding text.

The options enable you to select specific tables for import. Having selected the desired tables, you can hide the filter by clicking Hide Filter.

The other sections, such as MySQL Routine Objects, have similar filters available.

Click Execute to continue to the next step.

The wizard then imports objects, displaying the tasks that have been carried out and whether the operation was successful. If errors were generated, you can click Show Logs to see the nature of the errors. The next figure shows an example of the operational progress, which completed successfully.

Figure 9.48 Reverse Engineer Progress

Content is described in the surrounding text.

Click Next to continue to the next step.

The final step of the wizard provides a summary of the reverse-engineered objects, as the following figure shows.

Figure 9.49 Results

Content is described in the surrounding text.

Click Finish to close the wizard.

Before closing MySQL Workbench, save the schema. Click File and then Save from the menu to save the reverse-engineered database as a MySQL Workbench file with the extension mwb. Errors During Reverse Engineering

During reverse engineering, the application checks for tables and views that duplicate existing names and disallows duplicate names if necessary. If you attempt to import an object that duplicates the name of an existing object you will be notified with an error message. To see any errors that have occurred during reverse engineering, click Show Logs. This action will create a panel containing a list of messages, including any error messages than may have been generated. Click Hide Logs to close the panel.

If you plan to import an object with the same name as an existing object, rename the existing object before reverse engineering.

If you import objects from more than one schema, there will be a tab in the Physical Schemas area of the MySQL Model page for each schema imported.

You cannot reverse-engineer a live database that has the same name as an existing schema. To reuse a schema name, you must first rename the existing schema.

User Comments
User comments in this section are, as the name implies, provided by MySQL users. The MySQL documentation team is not responsible for, nor do they endorse, any of the information provided here.
  Posted by Kemin Zhou on August 7, 2013
For some reason, the relationships (Foreign keys) are not reflected in the final ER diagram. Not sure this is because that I am using the free version or it is a defect of this module (reverse engineering).

  Posted by Bert de Jong on September 19, 2017
For those of you who, like Mr. Zhou, are wondering why relationships do not show up. There are usually two reasons:
1. Workbench does not guess relationships based on column names. For instance, if your table "test" has a "class_id" column, Workbench does not assume this column has a relationship with the "id" column in the "class" table. You will have to ALTER TABLE `test` ADD FOREIGN KEY (classid) REFERENCES `class`(id);
2. Workbench silently ignores foreign keys if the storage engine is MyISAM. You will have to switch to InnoDB and then re-add the foreign key. If the foreign key fails, use a query like this to figure out why and then update row data: SELECT a.* FROM a LEFT JOIN b ON = WHERE IS NULL;
Sign Up Login You must be logged in to post a comment.