解決MySQL導入數據時遇到secure-file-priv的問題


使用以下mysql命令導入數據到mysql表時遇到

“MySQL server is running with the –secure-file-priv” Error

mysql> LOAD DATA LOCAL INFILE '/path/pet.txt' INTO TABLE pet;

 

原因在於“secure_file_priv”這個設置的值,默認是NULL,這就禁止了我們導入數據。

使用 show variables like %secure% 可以查看“secure_file_priv”的默認配置。

 

MySQL官網對這個配置的說明

https://dev.mysql.com/doc/refman/8.0/en/option-files.html

 

 

在哪里去更改這個配置呢,請看mysql官網的答案

https://dev.mysql.com/doc/refman/8.0/en/option-files.html

 

因為我用的是docker mysql,所以我的這個配置在/etc/mysql/my.cnf

用vi或者vim打開/etc/mysql/my.cnf,可見它的默認值是NULL,把這個默認值改成上面官網里面的其它兩個值之一就可以了。

 

然而,這並不能解決docker mysql的問題,之后導入數據時會報不支持此版本的問題。

so,果斷放棄。

哪來這么麻煩,直接用navicate之類的客戶端導入數據,完美解決。

 

參考鏈接:

secure_file_priv

https://computingforgeeks.com/how-to-solve-mysql-server-is-running-with-the-secure-file-priv-error/

 

start/stop/restart 啟動 停止重啟mysql的各種方法

https://coolestguidesontheplanet.com/start-stop-mysql-from-the-command-line-terminal-osx-linux/

 

MySQL官網 load date into table,這個有個用於示例的數據庫表。

https://dev.mysql.com/doc/refman/8.0/en/loading-tables.html

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM