Mysql 報(bào)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;

里面肯定有默認(rèn)設(shè)置的文件夾,
可以有兩種方案解決
1.把要上傳的文件放到你設(shè)置的文件目錄內(nèi),

  1. Disable secure-file-priv.
    必須修改配置文件my.ini.
#secure-file-priv="datadir="C:\AppServ/MySQL/Uploads"

修改后重啟mysql服務(wù)

mysql> select @@global.secure_file_priv;
+---------------------------+
| @@global.secure_file_priv |
+---------------------------+
| NULL                      |
+---------------------------+
1 row in set (0.00 sec)

3,此時(shí)在此運(yùn)行

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

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

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