Jeets
Jeets

Reputation: 3367

Not able to run mysql query through batch file

I want to run a dos script to execute the following command:

C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqldump --opt --where='1 limit 1'  -h a.b.c.d  -u root -proot remotedb remotetable|mysql -u root -pcanada localdb

I am not able to run this script.If I do not put double quotes around the path it gives error as 'C:\Program' is not recognized as an internal or external command. If I put double quotes around the path then also it fails with following error: "mysqldump: Got error: 1049: Unknown database 'limit' when selecting the database"

Could anyone suggest how I could run this query in script.It runs perfect when i run it directly through command line.Problem comes when i try to run it through batch ie .cmd file. Thanks in advance:)

Upvotes: 1

Views: 839

Answers (1)

Joey
Joey

Reputation: 354406

Try

"C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqldump" --opt --where="1 limit 1" -h a.b.c.d -u root -proot remotedb remotetable

You have to quote the path because it contains spaces and cmd doesn't treat single quotes as anything special.

Upvotes: 1

Related Questions