Latest Post

Error: No input file specified.

While trying to run a codeigniter app the other day I came across this error just after I had finished uploading the files and making the ne...

Saturday, November 30, 2013

DOS - Auto execute mysql scripts in a folder

I recently had to run multiple *.sql scripts on a mysql database on my dev machine. My first thought was to do a quick google search to see if i could get a quick and easy example i could just copy/paste/edit/run but i had no such luck unfortunately. Then i remembered I could use my old school DOS knowledge to get a listing of the sql files and recursively run mysql < script.sql on each of these files. I ended up with the following DOS command and it worked like a charm:

for /f %f in ('dir /b c:\FOLDER\WHERE\SQL\SCRIPTS\ARE') do mysql -u root <%f

Note that this was a quick fix on a dev pc that has root with no password

No comments:

Post a Comment

Chitika Ads