Windows Batch MySQL Create New Database

If you have a software that you have developed to be run on a local machine, and you need to update or delete the database, how would you be able to do it on the command line script.

Batch File

To keep the story short, creating batch files sometime helps if all you need is one file and you just have to include every command in the batch file.

How do we do that?
Imagine deploying any changes to the whole database that you really need to update a new database.

mysql -uusername -pyourpassword -e “drop database databasename”
mysql -uusername -pyourpassword -e “create database databasename”

What does the above mean?
In order to be able to perform the above, you need to create a text document with the above commands and inside and then rename it as something.bat. After doing so, you can perform this on a directory which enables you to run mysql.

Let’s say a folder in C:\wamp\bin\mysql\mysql5.4\bin, and then running the batch file would be able to perform the above scenario.

Leave a Reply