LOAD DATA INFILE Error Code : 13(加载数据文件错误代码:13)
问题描述
在我的远程 MySQL 中,当我尝试执行此查询时,我收到 MySQL 错误代码:13.
In my remote MySQL, when I try to execute this query, I am getting the MySQL Error Code : 13.
查询 -
LOAD DATA INFILE
'/httpdocs/.../.../testFile.csv'
INTO TABLE table_temp
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\\r \\n'
(sku, qty);
错误代码: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.我还将文件和文件夹权限设置为 chmod 777 (rwxrwxrwx)使用FTP工具
b. I have also set the file and folder permission to chmod 777 (rwxrwxrwx) using FTP Tool
推荐答案
我知道这个帖子很旧,但是搜索结果中仍然出现这个.我在网上找不到这个问题的解决方案,所以我最终自己解决了这个问题.如果您使用的是 Ubuntu,那么有一个名为Apparmor"的程序会阻止 MySQL 看到该文件.如果您希望 MySQL 能够从tmp"目录读取文件,您需要执行以下操作:
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
进入文件后,您将看到一堆 MySQL 可以使用的目录.将行 /tmp/** rwk 添加到文件中(我不确定它放在哪里很重要,但这里是我放置它的位置的示例):
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,
现在您需要做的就是重新加载 Apparmor:
Now all you need to do is reload Apparmor:
sudo /etc/init.d/apparmor reload
请注意,我使用了vim",但可以将其替换为您最喜欢的、您知道如何使用的文本编辑器.
Note I used "vim", but substitute that with whatever your favorite text editor is that you know how to use.
这篇关于加载数据文件错误代码:13的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:加载数据文件错误代码:13
基础教程推荐
- 在 SQL 中连接多个表 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- 无法解决整理冲突 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
