In Oracle SQLPlus, I can write:
set termout off
spool data.out
@query.sql
spool off
to make sure the query output is sent to the file data.out
and not to the terminal. Is there a way I can do the same in MySQL?
You can use
mysql> tee data.out
mysql> source query.sql
mysql> notee
and it will copy the output to the file, but it will also show it on the terminal. I don't think there's a way to disable the terminal output completely.
You could execute the command from the shell instead of the mysql>
interactive session, and use the shell's output redirection.
mysql < query.sql > data.out