现在的位置: 首页 > 综合 > 正文

关于mysql的LOAD DATA INFILE 语句

2013年08月30日 ⁄ 综合 ⁄ 共 793字 ⁄ 字号 评论关闭
今天在Linux上面用mysql的LOAD DATA INFILE  命令导入文本中的数据到数据库,但是在执行的时候总是抛出下面的错误  

ERROR 13 (HY000): Can't get stat of 'XXXX.xxx' (Errcode: 13)

但是将

LOAD DATA INFILE

 

换成

LOAD DATA LOCAL INFILE 

便可以正确的执行,经过探索发现估计是文件的权限问题,但是具体原因还有待探索,下面是国外网站对该问题的一个解释,供参考

This means the file doesn't exist.  The trick is that MySQL looks
for files in its data directory.  You need to specify the full path
to the file:

    LOAD DATA INFILE '/path/to/test.txt' ...

Or, you could use the LOCAL specifier to tell MySQL to load the file
through the client, instead of directly into the server:

    LOAD DATA LOCAL INFILE 'test.txt' ...

This second option isn't quite as efficient, but it will work even if
you are not on the same machine as the server, or if you don't have
FILE privileges.

None of the above really worked for me.What did work was a combination
of the two.You could try LOAD DATA LOCAL INFILE '/path/to/test.txt'...
this may work if the above two don't.

 

抱歉!评论已关闭.