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?

asked Jun 17, 2013 at 11:06

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.

answered Jun 17, 2013 at 11:52
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 Commented Jun 17, 2013 at 13:12

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.