How to recreate db during import of the dump? By recreate, db drop or deletion of its data is meant.
mysql db -u root -p < dump.sql
It's possible of course to drop and create db manually or automate it using bash, but as import is run frequently, i would like it to be done automatically via mysql command if it's possible.
asked Jun 25, 2017 at 21:12
2 Answers 2
You need to add this mysql command in order to drop and create database in a dump script:
DROP DATABASE IF EXISTS `database_name`;
CREATE DATABASE `database_name`;
Anthony Genovese
2,0673 gold badges22 silver badges34 bronze badges
answered Jun 26, 2017 at 14:35
mysqldump ... --add-drop-database ...
Check out the vast number of other options, too.
answered Jul 5, 2017 at 9:57
lang-sql