MySQL query with an OUTFILE to csv not working when called from a batch file
I bet that the double quote is the culprit: it terminates the string at ENCLOSED BY ', and the rest derails the whole thing.  The solution is very simple: just escape the double quote in your SQL string:

... ENCLOSED BY '\"' ...


(I have to tell that on my local Windows box and psql (instead of mysql) client I don't have to escape the double quote.)