'LOAD DATA INFILE'需要指导

时间:2014-06-16 14:19:06

标签: mysql linux

我创建了一个名为' /root/jyoti/test.txt'的文件;以下内容:

tail /root/jyoti/test.txt
20,'Daily','Complete'
21,'Daily','Complete'
22,'Daily','in-progress'

然后尝试跟踪查询以在mysql表中加载数据说' test'

mysql> select * from test;
+----+-----------+------------+
| id | testname  | testtype   |
+----+-----------+------------+
|  2 | Daily     | Complete   |


mysql> load data infile '/root/jyoti/test.txt' into table accounts fields terminated by ',' (id,testname,testtype);
ERROR 13 (HY000): Can't get stat of '/root/jyoti/test.txt' (Errcode: 13)

在另一篇文章中,我发现有人建议使用“加载数据本地信息”。而不是加载数据infile',但这也失败了,错误。

mysql> load data local infile '/root/jyoti/test.txt' into table accounts fields terminated by ',' (id,testname,testtype);
ERROR 1148 (42000): The used command is not allowed with this MySQL version

我正在使用以下MySql版本: -

mysql -V
mysql  Ver 14.14 Distrib 5.5.37, for debian-linux-gnu (x86_64) using readline 6.2
cat /etc/issue
Debian GNU/Linux 7 \n \l

该文件具有以下权限:

stat /root/jyoti/test.txt
  File: `/root/jyoti/test.txt'
  Size: 67              Blocks: 8          IO Block: 4096   regular file
Device: de00b6d1h/3724588753d   Inode: 554931      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2014-06-16 12:33:34.122226597 +0530
Modify: 2014-06-16 12:33:34.122226597 +0530
Change: 2014-06-16 12:33:34.488226595 +0530
 Birth: -

1 个答案:

答案 0 :(得分:0)

您可以启用加载本地文件:

--local-infile=1

启动mysql客户端时。通常默认情况下禁用它。