最近在进行MySQL学习时,发现导入文件一直出错,显示ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement。
看了网上的很多办法都不成功,后来发现原来是因为在MySQL 5.7.6版本之后,导入文件只能在secure_file_priv指定的文件夹下
所以用show variables like '%secure%';命令显示文件目录
+--------------------------+-----------------------+
| Variable_name | Value |
+--------------------------+-----------------------+
| require_secure_transport | OFF |
| secure_auth | ON |
| secure_file_priv | /var/lib/mysql-files/|
+--------------------------+-----------------------+
3 rows in set (0.00 sec)
这样将导入文件放在 /var/lib/mysql-files/文件夹下,之后再从这里导入就可以了
load data infile '/var/lib/mysql-files/part.csv' into table PART fields terminated by ',' optionally
enclosed by '"' escaped by '"' lines terminated by '\r\n';
如果显示ERROR 1261 (01000): Row 1 doesn't contain data for all columns
这个错误,是因为数据行不匹配,默认不能有空,用下列命令解决set sql_modul = 0;
本文介绍了如何解决MySQL在导入文件时出现的ERROR1290和ERROR1261错误。针对不同错误提供了具体的解决方案,并指出了在MySQL5.7.6及以后版本中文件路径配置的重要性。
1307

被折叠的 条评论
为什么被折叠?



