ERROR 2 (HY000): File '...........................' not found (Errcode: 2)

LOAD DATA LOCAL INFILE  '...'  
INTO TABLE `d_bigdata`.`IP_residence_all_2018W06_single_BD09_WGS84`  
CHARACTER SET utf8  
FIELDS TERMINATED BY '\t'  
ENCLOSED BY '\"'  
LINES TERMINATED BY '\n'  IGNORE 1 LINES;

上面这段代码在mysql中报错

解决方案:

  1. 文件权限问题
    这个文件一定要能被mysql读到,可以先chmod 777

  2. 文件所在路径权限问题
    同上

  3. 账号权限问题
    查看自己的权限

File权限

必须有File 权限才能使用 LOAD DATA LOCAL INFILE

  1. 文件格式问题
    这个问题我没遇过

  2. 服务器端配置
    https://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html#sysvar_local_infile

local_infile

Property    Value
Command-Line Format --local-infile[={OFF|ON}]
System Variable local_infile
Scope   Global
Dynamic Yes
Type    Boolean
Default Value   ON

This variable controls server-side LOCAL capability for LOAD DATA statements. Depending on the local_infile setting, the server refuses or permits local data loading by clients that have LOCAL enabled on the client side.

To explicitly cause the server to refuse or permit LOAD DATA LOCAL statements (regardless of how client programs and libraries are configured at build time or runtime), start mysqld with local_infile disabled or enabled, respectively. local_infile can also be set at runtime. For more information, see Section 6.1.6, “Security Issues with LOAD DATA LOCAL”.

服务端配置了--local-infile=ON,客户端才能用LOAD DATA LOCAL INFILE
客户端连接必须加--local-infile参数

mysql -h... -u... -p'...' -D...  --local-infile

LOAD DATA 语法
https://dev.mysql.com/doc/refman/5.7/en/load-data.html

加了 local 后,就可以从客户端读取文件加载到服务端

你可能感兴趣的:(ERROR 2 (HY000): File '...........................' not found (Errcode: 2))