【问题标题】:ERROR 1 (HY000) at line 1: (Errcode: 13 "Permission denied")第 1 行的错误 1 ​​(HY000): (Errcode: 13 "Permission denied")
【发布时间】:2021-09-25 07:11:13
【问题描述】:

我必须将我的SQL 查询输出保存在一个文本文件中。当我运行所需的查询时:

mysql -u root -p nextcloud -e "select * from oc_share INTO OUTFILE '/root/sql/test.txt'"

..它会抛出这个错误:

ERROR 1 (HY000) at line 1: Can't create/write to file '/root/sql/test.txt' (Errcode: 13 "Permission denied")

为什么会这样。我正在使用 Ubuntu 20.04。

【问题讨论】:

  • 需要更多信息。您使用什么程序运行查询?什么版本?等谢谢。
  • 请分享更多细节。 MySQL进程是否有写入/root的权限?

标签: mysql linux


【解决方案1】:

由于secure_file_priv,您无权访问目录/root/sql。请执行SHOW VARIABLES LIKE "secure_file_priv"; 并查看您可以将哪个目录用于outfile。这个参数可以通过my.cnf或者cmd来设置。

mysql> show variables like'%secure_file_priv%';
+------------------+-----------------------+
| Variable_name    | Value                 |
+------------------+-----------------------+
| secure_file_priv | /var/lib/mysql-files/ |
+------------------+-----------------------+

【讨论】:

    猜你喜欢
    • 2019-01-11
    • 1970-01-01
    • 2019-11-29
    • 2010-11-02
    • 2021-08-22
    • 2014-05-10
    • 2019-12-14
    • 2018-07-21
    • 2016-06-06
    相关资源
    最近更新 更多