Solved

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

Posted on 2009-04-13
2
898 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
ID: 24135069
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
ID: 24144900
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

815 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

9 Experts available now in Live!

Get 1:1 Help Now