将 MySQL 源结果输出到日志文件 [英] Output MySQL source results to log file
问题描述
我正在尝试使用 MySQL 中的 source 命令执行 foo.sql.
I am trying to execute foo.sql using the source command in MySQL.
当我输入命令时,文件是相应的:
When I type the command, the file is sourced accordingly:
mysql> source ~/foo.sql
现在,这个文件中有很多语句正在执行,我想回顾一下这些语句的成功/失败.有没有办法将语句的结果通过管道传输到日志文件 foo.txt?
Now, there are a lot of statements being executed in this file and I would like to review the success/failure of these statements. Is there a way I can pipe the results of the statements to a log file, foo.txt?
我在思考以下问题:
mysql> source ~/foo.sql into outfile ~/foo.txt
但是,输入此命令似乎假定源语句后面的所有内容都是一个文件名;所以它试图将一个名为 '~/foo.sql 的文件导入到 outfile ~/foo.txt' 中,该文件显然不存在.
However, typing this command appears to assume that everything following the source statement is one file name; so it is trying to source a file named '~/foo.sql into outfile ~/foo.txt', which obviously doesn't exist.
推荐答案
在你的 MySQL 客户端中,输入
From within your MySQL client, type
tee session.out
从那时起,您当前客户端会话中的所有 I/O 都将写入文件session.out"
From that point on, all the I/O of in your current client session is written to the file 'session.out'
这篇关于将 MySQL 源结果输出到日志文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!