我在使用 Mysql - "about query logging issue" 时遇到问题?

I am having troubles with Mysql - "about query logging issue"?

我想将 mysql 的查询保存到桌面上的 .out/.log/.txt 文件中。我正在使用 Mac 机器。我看到我的朋友在 mysql 中使用 "tee" linux 命令来记录像

这样的查询
tee ~/Desktop/mylog.txt

以上命令在他的笔记本电脑上运行 运行 windows 但显示错误-

( Can't create/write to file '~/Desktop/mylog.txt' (Errcode: 2 - No such file or directory)
Error logging to file '~/Desktop/mylog.txt') 

在我的笔记本电脑上。一旦我尝试在桌面上没有文件的情况下让它创建一个,然后我就预先创建了一个。但在这两种情况下它都不起作用。

然后我也尝试了下面这个:-

mysqld --log=~/Desktop/myquery.log

这也行,但会报错:

mysqld: Can't change dir to '/usr/local/mysql-5.7.18-macos10.12-x86_64/data/' (Errcode: 13 - Permission denied)
2017-09-05T08:35:50.566311Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-09-05T08:35:50.567503Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2017-09-05T08:35:50.567630Z 0 [Note] mysqld (mysqld 5.7.18) starting as process 25981 ...
2017-09-05T08:35:50.602972Z 0 [Warning] Can't create test file /usr/local/mysql-5.7.18-macos10.12-x86_64/data/Lohitakshs-MacBook-Air.lower-test
2017-09-05T08:35:50.603050Z 0 [Warning] Can't create test file /usr/local/mysql-5.7.18-macos10.12-x86_64/data/Lohitakshs-MacBook-Air.lower-test
2017-09-05T08:35:50.603305Z 0 [ERROR] failed to set datadir to /usr/local/mysql-5.7.18-macos10.12-x86_64/data/
2017-09-05T08:35:50.603328Z 0 [ERROR] Aborting

2017-09-05T08:35:50.606324Z 0 [Note] Binlog end
2017-09-05T08:35:50.608285Z 0 [Note] mysqld: Shutdown complete

然后我也尝试了 SUDO ,但这也给出了同样的错误。

现在我的问题是现在我的屏幕上有太多查询,我无法承受,所以我需要一个解决方案来解决我的 运行 服务器上的问题。

非常感谢

mysql 程序无法理解您的主目录的 ~ shorthand。

如果您在执行 运行 mysql 命令时位于主目录中,则只需键入

mysql> tee Desktop/mylog.txt

如果没有,您需要输入完整路径。

mysql> tee /Users/yourusername/Desktop/mylog.txt