Take the 2-minute tour ×
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. It's 100% free, no registration required.

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
add comment

1 Answer

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.

Max.

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
add comment

Your Answer

 
discard

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.