#只运行,不导出
mysql> source /home/user/to_run.sql; #导出
$ mysql -h host -u user -ppassword database < to_run.sql | sed 's/\t/,/g' > out.csv
或者
$ mysql -h host -uUSER -pPASSWORD --default-character-set=utf8 -A DATABASE -e 'select id from DATABASE.TABLE order by id;' > /tmp/XXX.csv