由于在mysql交互模式下执行导出命令要求设置secure-file-priv=...,否则会出现错误信息:
The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
而执行以下命令更方便,所以强烈推荐。
mysql -h HOSTNAME -uroot -p -D DATABASE -Bse "SELECT * FROM _TABLE" | sed 's/\t/","/g;s/^/"/;s/$/"/;s/\n//g' > FILE_NAME.csv