Mysql – Using a thesqldump export to create data with a different database name

MySQLmysqldump

I am using the following to import database using a mysqldump export:

mysql -u root -p example_db < path/to/export.sql

I would like to import the database to a database with a different name to the one referenced in export.sql. Is there a way to do this other than manually editing the export.sql file?

Best Answer

Use the option --no-create-db when you execute your mysqldump, this option avoid inserting CREATE DATABASE IF NOT EXISTS db_name; in dump file.

Max.