MySQL 中的 set termout off 等效于什么?

What is the equivalent of set termout off in MySQL?

在 Oracle SQLPlus 中,我可以写:

set termout off
spool data.out
@query.sql
spool off

确保查询输出发送到文件 data.out 而不是终端。有什么方法可以让我在 MySQL 中做同样的事情?

您可以使用

mysql> tee data.out
mysql> source query.sql
mysql> notee

它会将输出复制到文件中,但也会在终端上显示。我认为没有办法完全禁用终端输出。

您可以从 shell 而不是 mysql> 交互式会话执行命令,并使用 shell 的输出重定向。

mysql < query.sql > data.out