# mysqldump --add-drop-database option
--add-drop-database
is a mysqldump
option that is used to write a DROP DATABASE
statement before each CREATE DATABASE
statement. The option should be used in togheter with the option --all-databases
or --databases
because no CREATE DATABASE
statements are written unelss on of the two options is specified.
# Togheter with --all-databases option
mysqldump --add-drop-database --all-databases > my_backup.sql
# Togheter with --databases option
mysqldump --add-drop-database --databases my_first_db my_second_db > my_backup.sql
If the option is used without --all-databases
or --databases
, DROP DATABASE
statements will not be written because only those two options write CREATE DATABASE
statements.
# DROP DATABASE statements will not be written
mysqldump --add-drop-database > my_backup.sql