Create database via existing command line and overwrite

Asked

Viewed 1,552 times

4

I have a Function (Delphi) that creates processes and executes BAT files that make, for example, backup 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? Kind of:

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

Then I’d use it for popular:

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

The row to create the table does not work.

EDITION

I ended up discovering a code error or syntax, still 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 database without using "IF NOT EXISTS"?

1 answer

1


Deleta Database

Cria Database

Drop Database BD
Create Database BD
  • 1

    I thought in a single line, but really after searching for information it is necessary to drop before, so your simple answer is correct.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.