在匯入或匯出資料時,如何解決MySQL錯誤“ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement”?


MySQL出現此錯誤的原因有兩個:要麼`--secure-file-priv`變數未指定目錄,要麼在匯入或匯出資料時查詢中使用了錯誤的路徑。要解決此錯誤,必須透過以下查詢檢查`--secure-file-priv`變數的值:

mysql> Select @@global.secure_file_priv;
+---------------------------+
| @@global.secure_file_priv |
+---------------------------+
| C:\mysql\bin\mysql-files\ |
+---------------------------+
1 row in set (0.00 sec)

我們可以看到`secure_file_priv`變數下有一個路徑,匯出資料時所有檔案都將在此目錄下建立。

但是,如果以上命令的結果顯示為NULL,則表示未指定路徑,需要在匯出資料前在my.ini檔案中指定路徑。例如,如果在my.ini檔案中寫入`secure_file_priv = mysql-files/`,則`secure_file_priv`將具有如上的路徑作為其值。然後所有檔案都將在此目錄下建立。

更新於:2020年2月7日

1K+瀏覽量

開啟你的職業生涯

完成課程獲得認證

開始學習
廣告
© . All rights reserved.