Create database via command line and overwrite existing

4

I have a function (Delphi) that creates processes and executes BAT files that do, for example, backup of a MySQL BD, like this:

"C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqldump.exe" -u root -proot BD > "C:\dbbackup.sql"

Is there a command line that I can create the database on the server, just the database, and then use the backup SQL and create the populated tables?

"C:\Program Files\MySQL\MySQL Server 5.6\bin\mysql.exe" -u root -proot CREATE DATABASE BD

Then I would use this for popular:

"C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqldump.exe" -u root -proot BD < "C:\dbbackup.sql"

The line to create the table does not work.

EDITION

I ended up discovering a code or syntax error, keep working:

"C:\Program Files\MySQL\MySQL Server 5.6\bin\mysql.exe" -u root -
proot -e "CREATE DATABASE BD"

But how do I overwrite the existing bank without using "IF NOT EXISTS"?

    
asked by anonymous 02.06.2015 / 03:36

1 answer

1

Deleta Database

Create Database

Drop Database BD
Create Database BD
    
02.06.2015 / 13:20