错误1290:secure_file_priv

时间:2018-05-31 04:00:54

标签: mysql

我尝试从文件加载数据但得到ERROR 1290。

mysql> show variables like 'secure_file_priv';
+------------------+------------------------------------------------+
| Variable_name    | Value                                          |
+------------------+------------------------------------------------+
| secure_file_priv | C:\ProgramData\MySQL\MySQL Server 8.0\Uploads\ |
+------------------+------------------------------------------------+
1 row in set (0.01 sec)

mysql> load data infile "C:\ProgramData\MySQL\MySQL Server 8.0\Uploads\Book1"
into table sample fields terminated by ',';

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

我已经尝试过以下链接,但没有用。

  
    

MySQL ERROR 1290 (HY000) --secure-file-priv option

  

如何加载文件数据。

1 个答案:

答案 0 :(得分:1)

尝试:

档案:Z:\Path\To\MySQL Server 8.0\Uploads\Books

1,"Book0"
2,"Book1"
3,"Book2"

MySQL命令行:

mysql> SELECT VERSION();
+-----------+
| VERSION() |
+-----------+
| 8.0.11    |
+-----------+
1 row in set (0.00 sec)

mysql> SHOW VARIABLES WHERE `Variable_name` = 'secure_file_priv';
+------------------+--------------------------------------+
| Variable_name    | Value                                |
+------------------+--------------------------------------+
| secure_file_priv | Z:\Path\To\MySQL Server 8.0\Uploads\ |
+------------------+--------------------------------------+
1 row in set (0.00 sec)

CREATE TABLE `sample` (
  `id` INT NOT NULL PRIMARY KEY,
  `value` CHAR(5) NOT NULL
);

mysql> DROP TABLE IF EXISTS  `sample`;
Query OK, 0 rows affected (0.34 sec)

mysql> CREATE TABLE IF NOT EXISTS `sample` (
    ->   `id` INT NOT NULL PRIMARY KEY,
    ->   `value` CHAR(5) NOT NULL
    -> );
Query OK, 0 rows affected (0.36 sec)

mysql> LOAD DATA INFILE 'Z:\\Path\\To\\MySQL Server 8.0\\Uploads\\Books'
    -> INTO TABLE `sample`
    ->   FIELDS TERMINATED BY ','
    ->   OPTIONALLY ENCLOSED BY '"'
    ->   LINES TERMINATED BY '\r\n';
Query OK, 3 rows affected (0.08 sec)
Records: 3  Deleted: 0  Skipped: 0  Warnings: 0

mysql> SELECT `id`, `value`
    -> FROM `sample`;
+----+-------+
| id | value |
+----+-------+
|  1 | Book0 |
|  2 | Book1 |
|  3 | Book2 |
+----+-------+
3 rows in set (0.15 sec)