I want to execute a query inside a db.sql file using MySQL 5.1 in the Windows environment. Can any one help me with this? I want to do this by running a .bat file.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Col Shrapnel’s answer is the way to do it. The batch file would look like this:
…which really just shows that it’d just be easier to use that directly instead of a .bat.
Reading your comment on the other answer, it seems like you might actually get some use out of the batch file as long as you don’t mind storing your password in plain text on your computer.
Make the batch file like this:
Note that there is no space between
-pandmypassword. If you use that above, every script would have to specify which database to use, which might be a hassle. The other way you could do it is like this:And the usage would be: