select * from messages into outfile '/tmp/messages.csv' FIELDS TERMINATED BY ',';