Showing posts with label import database. Show all posts
Showing posts with label import database. Show all posts

Monday, January 30, 2017

Windows Batch Script to create new MySQL database and import

Create a file named restore.bat with following contents & double to click to create new database & import data to selected database

@ECHO OFF
cd C:\xampp\mysql\bin
mysql.exe -uroot -hlocalhost -e "drop database if exists some_db_name";
mysql.exe -uroot -hlocalhost -e "create database some_db_name default character set utf8 default collate utf8_general_ci;";
echo DB Created
mysql.exe -uroot -hlocalhost some_db_name < "C:\tmp\back_up.sql"
echo DB Restored
pause
exit;