Skip to content

Import a SQL dump from one schema into another with MySQL Workbench

When restoring a MySQL dump from MySQL Workbench, currently it is not possible to specify a different schema than the schema used during the export. The workaround for that is to edit the dump file (which is just a text file) in a text editor and change the name of the schema manually.

For example to change the schema name from ‘old_schema’ to ‘new_schema’, open the dump file in a text editor and change these two lines:

CREATE DATABASE  IF NOT EXISTS 'old_schema' /*!40100 DEFAULT CHARACTER SET utf8 */;
USE 'old_schema';

to this:

CREATE DATABASE  IF NOT EXISTS 'new_schema' /*!40100 DEFAULT CHARACTER SET utf8 */;
USE 'new_schema';

After that, import the dump file using MySQL Workbench as usual. Please note that if you exported the old schema with qualified identifiers you would also have to search and replace the schema name everywhere in the dump file, otherwise each object would have the old schema name as prefix.