Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

i want to use mysqldump so that it includes the statement to create database if not exists, and drop database if exists. is this possible? what options can I use?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

You can get MYSQLDump to drop the database before creating it by adding

--add-drop-database

To your MYSQLDump command. You should already have the create database command in there.

share|improve this answer
    
how do I make create table statement use namespace(db name) –  user12145 Jan 29 '11 at 15:56
    
Only to correct the source code client/mysqldump.c. mysqldump add 'USE DBNAME;' statement. –  alvosu Jan 29 '11 at 16:11
    
'IF NOT EXIST' added, if --databases or --all-databases option was given. –  alvosu Jan 29 '11 at 16:13
add comment

--add-drop-database and --database name(or --all-databases). If use mysqldump db_name --add-drop-database, DROP DATABASE and CREATE DATABASE not be added.

share|improve this answer
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.