SELECT INTO OUTFILE 无法写入文件

发布于 2024-10-04 00:51:05 字数 583 浏览 2 评论 0原文

我正在尝试执行 SELECT INTO OUTFILE 操作,但收到以下错误:

General error: 1 Can't create/write to file '/home/jason/projects/mcif/web/downloads/dump.csv' (Errcode: 13). Failing Query: "
SELECT name
INTO OUTFILE '/home/jason/projects/mcif/web/downloads/dump.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
FROM account a

我知道问题可能是什么:我的 downloads 文件夹无法由我的MySQL 用户。我不知道如何解决这个问题有两个原因:

  • 我不知道如何找出问题所在 MySQL 用户是
  • 我不知道如何将 MySQL 用户添加到能够写入

Ubuntu Linux 上的 downloads 文件夹的用户中。有人可以帮我克服这两件事吗?

I'm trying to do a SELECT INTO OUTFILE and I'm getting the following error:

General error: 1 Can't create/write to file '/home/jason/projects/mcif/web/downloads/dump.csv' (Errcode: 13). Failing Query: "
SELECT name
INTO OUTFILE '/home/jason/projects/mcif/web/downloads/dump.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
FROM account a

I know what the problem probably is: my downloads folder isn't writable by my MySQL user. I don't know how to solve this problem for two reasons:

  • I don't know how to find out what the
    MySQL user is
  • I don't know how to add the MySQL user to the users who are able to write to the downloads folder

I'm on Ubuntu Linux. Can someone help me get past those two things?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

剪不断理还乱 2024-10-11 00:51:05

写入文件 /tmp/dump.csv 并将其复制过来。这将让您看到谁在运行什么。我的猜测是,您是从网络上执行此操作,并且客户端作为网络服务器进程运行......

write the file /tmp/dump.csv and the copy it over.. That will let you see who is running what. My guess is that you are doing this from the web and the client is running as the web server process...

尐籹人 2024-10-11 00:51:05

mysql -u 用户名 --password=PASSWORD --database=DATABASE --execute='SELECT FIELD, FIELD FROM TABLE LIMIT 0, 10000 '-X>文件.xml

mysql -u USERNAME --password=PASSWORD --database=DATABASE --execute='SELECT FIELD, FIELD FROM TABLE LIMIT 0, 10000 ' -X > file.xml

于我来说 2024-10-11 00:51:05

这是一个可能有帮助的讨论:
如何让 MySQL 将输出文件写为不同的文件用户?

另外,请尽量避免用废话来掩盖你的问题。就您的情况而言,您已经知道这是权限问题,因此所有 SQL 连接和表都不重要。你可以简单地使用
您选择的一张表中的一个字段,可以演示问题而不会使事情变得混乱。

Here's a discussion that may help:
How can I have MySQL write outfiles as a different user?

Also, please try to avoid clouding your questions with fluff. In your case, you already know it's a permissions issue, so all of your SQL joins and tables don't matter. You could have simply used
one field from one table in your select, to demonstrate the problem without clouding things up.

我不在是我 2024-10-11 00:51:05

客户端可能是mysqld。您必须更改 apparmor 授权,它会正常工作。查看这个答案

the client will probably be mysqld. you must change apparmor authorizations and it will work fine. check out this answer

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文