Solved

How to create a MSDOS Batch Script to restore many .sql database ?

Posted on 2009-04-13
2
896 Views
Last Modified: 2012-05-06
Hi,

I would like to request an assistant.

May i know how to create a MSDOS Batch Script to restore many .sql database ?

FYI, all the .sql file which have been previously backup located at C:\DatabaseBackups\20090414_115405 folder.

I would like to restore all this mysql using a script because it have hundreds of .sql file.

Appreciates if anybody can help me.

Thank you.
0
Comment
Question by:smksa
2 Comments
 
LVL 21

Accepted Solution

by:
theGhost_k8 earned 500 total points
Comment Utility
Put this where all SQL files are stored. It will load one by one sql files to mysql

### loadsql.bat ####

echo off
for /f "tokens=*" %%a in ('dir /b *.sql') do  mysql -uUSER -pPASSWORD < %%a
pause
0
 
LVL 4

Expert Comment

by:dkaisla
Comment Utility
For windows, you can create a php file (one that will be run in command line) that reads .sql backup files through the directory and runs it to restore the databases(use exec() function for this). Then you can create the batch file to run the php file in command line.
Let me know if you have trouble with the code. :)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now