Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 1 down vote accepted

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.


share|improve this answer
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 '13 at 13:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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