MySQL query output to text or CSV

I needed to output the results of a MySQL query today for further analysis and found the answer here. For future reference…

SELECT * FROM errors WHERE mailfrom LIKE ‘a.n.other%’ INTO OUTFILE ‘/tmp/a.n.other.txt’ FIELDS TERMINATED BY ‘,’ LINES TERMINATED BY ‘\n’;

It is also possible to enclose the fields with quotes using: