Problem
You want to export a MySQL database table as a csv with something like:
mysql> select * from table_name into outfile '/tmp/table_name.csv';
but you get the error that MySQL cannot execute this command.
Solution
Find out the location that MySQL can use to export files by running the following:
mysql> show variables like 'secure_file_priv'; +------------------+-----------------------+ | Variable_name | Value | +------------------+-----------------------+ | secure_file_priv | /var/lib/mysql-files/ | +------------------+-----------------------+ 1 row in set (0.00 sec)
and then use the path to change the outfile path (ie /var/lib/mysql-files/table_name.csv).
Taken from the answer here