mysql - mysqldump with create database line -
i'm in process of moving files onto computer, , 1 thing transfer data in mysql database. want dump databases .sql files, have create database db_name including in file, way have import file mysql without having manually create databases. there way that?
by default mysqldump creates create database if not exists db_name; statement @ beginning of dump file.
[edit] few things mysqldump file , it's options:
--all-databases, -a
dump tables in databases. same using --databases option , naming databases on command line.
--add-drop-database
add drop database statement before each create database statement. option typically used in conjunction --all-databases or --databases option because no create database statements written unless 1 of options specified.
--databases, -b
dump several databases. normally, mysqldump treats first name argument on command line database name , following names table names. option, treats name arguments database names. create database , use statements included in output before each new database.
--no-create-db, -n
this option suppresses create database statements otherwise included in output if --databases or --all-databases option given.
some time ago, there similar question asking not having such statement on beginning of file (for xml file). link question is here.
so answer question:
- if have 1 database dump, should have
--add-drop-databaseoption inmysqldumpstatement. - if have multiple databases dump, should use option
--databasesor--all-databases,create databasesyntax added automatically
more information @ mysql reference manual
Comments
Post a Comment