ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

我在将csv文件里面的数据导入数据表时,用命令

LOAD DATA INFILE '/home/sampledata.csv' into table info FIELDS TERMINATED BY ',' IGNORE 1 LINES;

报如下错误

MySQL数据库将CSV文件数据导入表报ERROR 1290 (HY000):

查了好多相关资料,是权限问题导致的,于是乎我用show variables like ‘%secure%’;这条语句查询了这个secure_file_priv 参数的值,具体方法如下:

MySQL数据库将CSV文件数据导入表报ERROR 1290 (HY000):

原来是我的csv文件没有放到/var/lib/mysql-files/路径下, 

后面我将要导入的csv数据文件移动到/var/lib/mysql-files/路径下,然后用chmod命令修改了了csv文件的权限

mv /home/sampledata.csv /var/lib/mysql-files/

chmod 777 sampledata.csv

再进入数据库执行导入语句

load data infile '/var/lib/mysql-files/sampledata.csv' into table info fields terminated by ','  optionally y enclosed by '"' escaped by '"' lines terminated by '\r\n' IGNORE 1 LINES;

如下图所示导入成功啦!

MySQL数据库将CSV文件数据导入表报ERROR 1290 (HY000):

查询下数据是否导入成功

MySQL数据库将CSV文件数据导入表报ERROR 1290 (HY000):

 

相关文章: