Mysql使用load data local infile导入数据,Error 3948和Error 2068报错,已解决
①ERROR 3948 (42000): Loading local data is disabled; this must be enabled on both the client and server sides,以下解决方法是针对全局变量local_infile未打开,即是OFF的情况,具体步骤如下:
登陆Mysql,输入:
show global variables like 'local_infile';
显示 Value=OFF,
再输入:
set global local_infile=on;
把这个值变为 ON,
exit退出mysql,再重新登陆,再次检查全局变量local_infile的状态,已经变为ON。
完成上述步骤后,用load data local infile又出现了Error2068错误,解决如下:
② ERROR 2068 (HY000): LOAD DATA LOCAL INFILE file request rejected due to restrictions on access.
需要以mysql -u 用户名 -p --local-infile的命令登陆,如:
mysql -u root -p --local-infile
即可正常使用命令,如load csv文件到yourtable:
LOAD DATA LOCAL INFILE "D:\\JupyterNotebook_Index\\UserBehavior_sql.csv"
-> INTO TABLE user_behavior
-> FIELDS TERMINATED BY ","
-> LINES TERMINATED BY "\n";