操作环境: workbench MySQL5.7
问题描述
在workbench中建好表之后,通过下面的命令导入外部数据出现Error Code2068;
load data local infile 'E:\\student_info.txt'
into table student_info character set utf8 fields terminated by ',' ignore 1 lines;
实际在workbench中导入外部数据不同于在cmd命令窗口操作MySQL,不用 "local" 命令,但是去掉 "local"仍然出错;
load data infile 'E:\\student_info.txt'
into table student_info character set utf8 fields terminated by ',' ignore 1 lines;
执行此命令出现:Error Code: 1290. The MySQL server is running with the --secure-file-priv option so it cannot execute this statement. 说明此路径下的数据导入是不允许的。
问题解决
首先我们需要找到在workbench中导入如外部数据所允许的路径;
show variables like '%secure%';
#输入此命令找到所允许操作的路径
将要导入的外部数据移至此路径下;
在workbench中执行以下命令即可成功导入数据;
load data infile 'C:\\ProgramData\\MySQL\\MySQL Server 5.7\\Uploads\\student_info.txt'
into table student_info character set utf8 fields terminated by ',' ignore 1 lines;
查看数据是否导入成功;
成功导入;