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
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
-
1Thanks. Just for reference. I discovered that using
--databases db_name
in the mysqldump resulted in theUSE 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– xylar2013年06月17日 13:12:02 +00:00Commented Jun 17, 2013 at 13:12
lang-sql