1

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?

1 Answer 1

1

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.

1
  • 1
    Thanks. Just for reference. I discovered that using --databases db_name in the mysqldump resulted in the USE db_name in the export. So the following is a guide to working dump with no USE nor CREATE: mysqldump -u root -p db_name --no-create-db > path/export.sql
    – xylar
    Jun 17, 2013 at 13:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.