look at link
you only need to add this to the query
select * from table INTO OUTFILE '/tmp/myfilename.txt'
you can improve this to csv file (using it in excel latter)
like :
INTO OUTFILE '/tmp/myfilename.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'