0

I am trying to export mysql table data to csv file using batch file. It works on the screen but not able to ouptut to a csv file.

 @echo off
    " C:\ProgramFiles\MYSQL\MYSQL Workbench 6.3 CE\mysql.exe" mysql -uroot -ppassword -e "select plate form SWP;" > \output.csv
    pause
    exit
9
  • \output.csvwierd path looks to me as a invalid windows path. Use more something like C:/output.cvs Commented Jul 9, 2018 at 14:59
  • 1
    maybe it should also be in double qoutes. Commented Jul 9, 2018 at 15:00
  • 3
    @RaymondNijland, the "weird" path \output.csv points to the file output.csv in the current drive; it is valid, but might be unintended; using C:/output.csv is not recommended (though it might work) as the Windows path separator is \ ... Commented Jul 9, 2018 at 15:06
  • 1
    Since the problem seems to be caused by a simple typo, this question should be deleted in my opinion, because it is not going to help other users... Commented Jul 9, 2018 at 15:07
  • 2
    @RaymondNijland, to explicitly point to the current working directory, you would need to specify .\output.csv, which is equivalent to output.csv... Commented Jul 9, 2018 at 15:18

1 Answer 1

1

mysql got a feature for this : LOAD DATA INFILE This will load the content of a query in a file.

Check the doc here :

https://dev.mysql.com/doc/refman/5.7/en/load-data.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.