I am trying to do an export of one of my mysql tables to excel compatible csv and it works great from phpmyadmin but I want to script it via the command line. Most of the table fields are text and may contain commas, and possibly even quotes and single quote, etc. For some reason the phpmyadmin utility handles this well. I just hope that the CLI will to it correctly as well. One of the first stumbling blocks I am encountering now is that I need to include the doublequote character inside the single quote below, but I tried various variations, including escaping the double quote via '\"' but the command still won't run properly. That text below
Optionally enclosed by '"'
is what is giving me issues. How can this be fixed?
mysql -u root -ppassword ChangeTemplate -e "SELECT * INTO OUTFILE 'Changes.xls' FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' Optionally enclosed by '"' FROM ChangeTemplate.ChangeRecord;"
Thanks very much.