LOAD DATA INFILE错误代码:13 [英] LOAD DATA INFILE Error Code : 13

查看:209
本文介绍了LOAD DATA INFILE错误代码:13的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的远程MySQL中,当我尝试执行这个查询时,
我得到了MySQL错误代码:13.

查询 -

  LOAD DATA INFILE 
'/httpdocs/.../.../testFile.csv'
INTO TABLE table_temp
FIELDS TERMINATED BY','
'\\r \\'
(sku,qty);

错误代码: 13无法取得/ httpdocs /的统计资料。 ../.../testFile.csv'(Errcode:2)



a。数据库用户登录拥有所有授予特权。

  CREATE USER'userName'@'%'IDENTIFIED BY'***** *******'; 

授予*上的所有特权。 * TO'userName'@'%'IDENTIFIED BY'************'WITH GRANT OPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;

授予`userName \__%`的所有特权。 * TO'userName'@'%';



b。我也使用FTP工具将文件和文件夹权限设置为chmod 777(rwxrwxrwx)

这个帖子是旧的,但这仍然出现在搜索结果。我无法在网上找到这个问题的解决方案,所以我最终自己搞清楚了。如果您使用的是Ubuntu,那么有一个名为Apparmor的程序阻止MySQL查看该文件。如果你希望MySQL能够从tmp目录读取文件,你需要做的是:
$ b $ pre $ sudo vim / etc / apparmor.d / usr.sbin.mysqld

一旦进入文件,去看一堆MySQL可以使用的目录。将 / tmp / ** rwk 这一行添加到文件中(我不确定它在哪里,但这里是我放置它的示例):

  /etc/mysql/*.pem r,

/etc/mysql/conf.d/ r,

/etc/mysql/conf.d/* r,

/etc/mysql/*.cnf r,

/ usr / lib / mysql / plugin / r,

/usr/lib/mysql/plugin/*.so* mr,

/ usr / sbin / mysqld mr,

/ usr / share / mysql / ** r,

/var/log/mysql.log rw,

/var/log/mysql.err rw ,

/ var / lib / mysql / r,
$ b $ / var / lib / mysql / ** rwk,


/ tmp / ** rwk,


/ var / log / mysql / r,

/ var / log / mysql / * rw,

/var/run/mysqld/mysqld.pid w,

/var/run/mysqld/mysqld.sock w,

/ run / mysqld / mysqld。 pid w,

/run/mysqld/mysqld.sock w,

现在你需要做的就是重新加载Apparmor:
$ b $ pre $ sudo /etc/init.d/apparmor reload

code>

In my remote MySQL, when I try to execute this query, I am getting the MySQL Error Code : 13.

Query -

LOAD DATA INFILE 
'/httpdocs/.../.../testFile.csv'
INTO TABLE table_temp
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\\r \\n'
(sku, qty);

Error Code : 13 Can't get stat of '/httpdocs/.../.../testFile.csv' (Errcode: 2)

a. The database userlogin has all the grant priviliges.

CREATE USER 'userName'@'%' IDENTIFIED BY '************';

GRANT ALL PRIVILEGES ON * . * TO 'userName'@'%' IDENTIFIED BY '************' WITH GRANT OPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;

GRANT ALL PRIVILEGES ON `userName\_%` . * TO 'userName'@'%';

b. I have also set the file and folder permission to chmod 777 (rwxrwxrwx) using FTP Tool

解决方案

I know that this post is old, but this still comes up in search results. I couldn't find the solution to this problem online, so I ended up figuring it out myself. If you're using Ubuntu, then there is a program called "Apparmor" that is preventing MySQL from seeing the file. Here's what you need to do if you want MySQL to be able to read files from the "tmp" directory:

sudo vim /etc/apparmor.d/usr.sbin.mysqld

Once you are in the file, you're going to see a bunch of directories that MySQL can use. Add the line /tmp/** rwk to the file (I am not sure that it matters where, but here is a sample of where I put it):

  /etc/mysql/*.pem r,

  /etc/mysql/conf.d/ r,

  /etc/mysql/conf.d/* r,

  /etc/mysql/*.cnf r,

  /usr/lib/mysql/plugin/ r,

  /usr/lib/mysql/plugin/*.so* mr,

  /usr/sbin/mysqld mr,

  /usr/share/mysql/** r,

  /var/log/mysql.log rw,

  /var/log/mysql.err rw,

  /var/lib/mysql/ r,

  /var/lib/mysql/** rwk,


  /tmp/** rwk,


  /var/log/mysql/ r,

  /var/log/mysql/* rw,

  /var/run/mysqld/mysqld.pid w,

  /var/run/mysqld/mysqld.sock w,

  /run/mysqld/mysqld.pid w,

  /run/mysqld/mysqld.sock w,

Now all you need to do is reload Apparmor:

sudo /etc/init.d/apparmor reload

Note I used "vim", but substitute that with whatever your favorite text editor is that you know how to use.

这篇关于LOAD DATA INFILE错误代码:13的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆