Mysql 報The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

場景:

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.把要上傳的文件放到你設置的文件目錄內(nèi),

  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, 不使用絕對路徑,把要上傳的文件復制到數(shù)據(jù)庫對應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 |
+----+-----------+------+-----------+------+
最后編輯于
?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容