I am making a mysql query to a remote host and after many many hours of failure have learned a query containing "to outfile" means save the file on the remote server not the local host.
Make the query from the local host, not from a session on the remote host