Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL Dump All Databases and Create (or Recreate) them on Import?

I was wondering how I can get the following file,

mysqldump -h server -u root -p --all-databases > all_dbs.sql 

to automatically create any databases that are not yet created, when imported. Also, if a database is already present, it should recreate it (overwriting the old one).

Is this possible? Thanks!

like image 514
Garrett Avatar asked Jan 20 '11 16:01

Garrett


1 Answers

Export: mysqldump -u root -p --all-databases > all_dbs.sql Import: mysql -u root -p < all_dbs.sql 
like image 123
Garrett Avatar answered Oct 11 '22 08:10

Garrett