【问题标题】:Need Guidance with 'LOAD DATA INFILE'需要'LOAD DATA INFILE'的指导
【发布时间】:2014-06-16 14:19:06
【问题描述】:

我创建了一个名为“/root/jyoti/test.txt”的文件,其内容如下:

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

然后尝试以下查询以将数据加载到 mysql 表中说“测试”

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)

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

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: -

【问题讨论】:

    标签: mysql linux


    【解决方案1】:

    您可以通过以下方式启用加载本地文件:

    --local-infile=1
    

    当你启动 mysql 客户端时。它通常默认禁用。

    【讨论】:

    • 你能给我具体的步骤吗?任何工作的 sn-p 都会更有帮助。我尝试使用选项“--local-infile=1”登录 mysql,但仍然没有帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-04-27
    • 2013-01-14
    • 2016-07-30
    • 2011-05-28
    • 2012-10-05
    • 2010-11-17
    • 1970-01-01
    相关资源
    最近更新 更多