Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2009-04-13
2
899 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

856 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