【发布时间】:2018-02-13 19:52:13
【问题描述】:
我想将我的 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 ,但这也给出了同样的错误。
现在我的问题是我的屏幕上现在有太多的查询,我不能松懈,所以我需要一个可以解决我正在运行的服务器上的问题的解决方案。
非常感谢
【问题讨论】:
-
看不懂
~的简写,输入完整的路径名:tee /Users/yourusername/Desktop/mylog.txt -
@Barmar cd ~ 将永远把你放在你的主目录中
-
@Barmar 您的解决方案有效,谢谢,我想现在我明白我的错误了
标签: mysql linux database macos backup