我在Windows 10计算机上运行MySQL 5.7。我已经阅读了有关该主题的所有SO线程,但仍然没有弄清楚如何加载我的数据并克服此错误:
Error Code: 1290. The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
我有1)检查设置以将其更改为能够从保存数据集的目录中加载,2)以管理员身份打开MySQL并检查了命令行,并确认安全文件确实指向我的目录,3)并在init文件中确认它指向包含我的文件的正确目录。我尝试更改数据集的位置,以便将其放置在新文件夹中,并确认已使用上述方法将其移动到该文件夹中,但仍无法正常工作。
任何帮助都将受到欢迎,谢谢。
我无法重现该问题。
mysql> SELECT VERSION(); +-----------+ | VERSION() | +-----------+ | 5.7.13 | +-----------+ 1 row in set (0,00 sec) mysql> SELECT @@GLOBAL.secure_file_priv; +---------------------------+ | @@GLOBAL.secure_file_priv | +---------------------------+ | NULL | +---------------------------+ 1 row in set (0,00 sec) -- USE ... mysql> LOAD DATA INFILE '/var/lib/mysql-files/myfile.csv' -> INTO TABLE `test_files` -> COLUMNS TERMINATED BY ',' ENCLOSED BY '\"' -> LINES TERMINATED BY '\n'; ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
变更档案: /etc/mysql/my.cnf
/etc/mysql/my.cnf
[mysqld] . . . secure_file_priv=/var/lib/mysql-files/ . . .
重新启动MySQL。
mysql> SELECT @@GLOBAL.secure_file_priv; +---------------------------+ | @@GLOBAL.secure_file_priv | +---------------------------+ | /var/lib/mysql-files/ | +---------------------------+ 1 row in set (0,00 sec) mysql> LOAD DATA INFILE '/var/lib/mysql-files/myfile.csv' -> INTO TABLE `test_files` -> COLUMNS TERMINATED BY ',' ENCLOSED BY '\"' -> LINES TERMINATED BY '\n'; Query OK, 3 rows affected (0,00 sec) Records: 3 Deleted: 0 Skipped: 0 Warnings: 0
请参阅6.1.4服务器系统变量:: secure_file_priv