在windows系統的MySQL8.0中嘗試執行以下語句時報錯
mysql> LOAD DATA LOCAL INFILE '/path/filename' INTO TABLE tablename;
ERROR 1148 (42000): The used command is not allowed with this MySQL version
所用的指令在當前MySQL版本不被允許,
但其實MySQL5.1及以上都支持此命令,報這個錯是因為MySQL中系統變量local-infile=0時不允許本地加載數據,在安裝目錄找到配置文件my.ini,修改其中的local-infile=1,或在啟動MySQL時添加--local-infile選項
mysql -uroot --local-infile=1 -p
password:******
ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
MySQL服務正在以--secure-file-priv選項運行,因此無法執行這個語句,
出錯的原因是因為在MySQL 5.7.6版本之后,導入文件只能在secure_file_priv指定的文件夾下(也有原因是因為權限不夠),我們可以用show variables like '%secure%';命令顯示文件目錄,把需要導入的文件放在secure-file-priv參數指定的文件夾下,之后再從這里導入就可以了
ERROR 2 (HY000): File not found (OS errno 2 - No such file or directory)
文件未找到,
在windows系統下提供文件路徑時需要將所有"\變為“\\”,如C:\\Program Files\\MySQL\\MySQL Server 8.0\\file