您的位置:首页 > 数据库 > MySQL

将MySQL中sql运行结果保存到文件

2016-11-09 17:02 405 查看
方法一:在mysql>提示符中使用tee

mysql> tee output.txt
Logging to file 'output.txt'
mysql> notee
Outfile disabled.
或者
mysql> \T output.txt
Logging to file 'output.txt'
mysql> \t
Outfile disabled.

这个类似于sqlplus的spool功能,可以将命令行中的结果保存到外部文件中。如果指定已经存在的文件,则结果会附加到文件中。

方法二:使用mysql命令行工具的--tee参数

$mysql --tee=ot.txt

Logging to file 'ot.txt'

mysql>

这回将所有的输入和输出内容都记录到指定的文件中(直到exit为止)。如果指定已经存在的文件,则结果会附加到文件中。

mysql> source d:/exchange.sql;
Query OK, 2 rows affected (0.00 sec)
Records: 2 Duplicates: 0 Warnings: 0
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mysql 导出