[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2009-04-13
2
Medium Priority
?
906 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:
K V earned 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
Starting up a Project
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

872 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