在匯入或匯出資料時,如何解決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`將具有上述路徑作為其值。然後所有檔案都將在此目錄下建立。
廣告
資料結構
網路
關係資料庫管理系統 (RDBMS)
作業系統
Java
iOS
HTML
CSS
Android
Python
C語言程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP