Create reusable MySQL schema dumps

September 16, 2010 by Michael

In case you need a MySQL schema transferred from one host to another and the schema names differ, you can ran into problems with a standard MySQL dump.

Use the following statement to create a schema dump that contains all table and view definitions as well as all stored procedures without a reference to the original schema:

 mysqldump -uroot -p name_of_the_original_schema --no-data --opt --routines | sed 's/`name_of_the_original_schema`.//g' > dump.sql

The dump will only contain the schema definition and no data. Calls to routines will not be prefixed with a schema name.

No comments yet

Post a Comment

Your email is never published nor shared. Required fields are marked *