场景:
mysql> load data infile 'C:\data.txt' into tab_load_data;
ERROR 1290 (HY000): The MySQL server is
on so it cannot execute this statement
排查:
mysql> select @@global.secure_file_priv;
里面肯定有默认设置的文件夹,
可以有两种方案解决
1.把要上传的文件放到你设置的文件目录内,
- Disable secure-file-priv.
必须修改配置文件my.ini.
#secure-file-priv="datadir="C:\AppServ/MySQL/Uploads"
修改后重启mysql服务
mysql> select @@global.secure_file_priv;
+---------------------------+
| @@global.secure_file_priv |
+---------------------------+
| NULL |
+---------------------------+
1 row in set (0.00 sec)
3,此时在此运行
mysql> load data infile "c:loads\tab_load_data.txt" i
-> table tab_load_data;
ERROR 29 (HY000): File 'C:\loads\tab_load_data.txt (Errcode: 2 - No such file or directory)
## 此时 报无此目录error, 不使用绝对路径,把要上传的文件复制到数据库对应data目录,C:\MySQL\data\data_name\tab_load_data.txt
> a
mysql> load data infile "tab_load_data.txt" int
-> table tab_load_data;
Query OK, 6 rows affected, 1 warning (0.03 sec)
Records: 6 Deleted: 0 Skipped: 0 Warnings: 1
mysql> select * from tab_load_data;
+----+-----------+------+-----------+------+
| id | name | sex | jiguan | f5 |
+----+-----------+------+-----------+------+
| 1 | zhagnsan | 男 | 江西 | 1 |
| 2 | 韩顺平 | 男 | 四川 | 2 |
+----+-----------+------+-----------+------+
网友评论