Export MySQL results to outfile/CSV

To export MySQL results to an outfile or CSV file:

SELECT column_name FROM table_name INTO OUTFILE '/var/lib/mysql-files/export.csv';

If you receive the following error:

The MySQL server is running with the –secure-file-priv option so it cannot execute this statement

This can be solved by following this post