問題描述
我正在使用 PHP mysqli 庫.每次我嘗試運行 LOAD DATA LOCAL INFILE
命令時,mysqli 都會抱怨消息
I am using the PHP mysqli library. Every time I try to run a LOAD DATA LOCAL INFILE
command, mysqli complains with the message
此 MySQL 版本不允許使用的命令
The used command is not allowed with this MySQL version
從 MySQL 終端(必須使用 --local-infile=1 登錄才能使其工作)或 PHPMyAdmin 運行命令時,我沒有遇到同樣的問題.只是我的 PHP+mysqli 代碼遇到了這個錯誤.
I do not have the same problem with running the command from a MySQL terminal (must login with --local-infile=1 to make it work) or PHPMyAdmin. Just my PHP+mysqli code experiences this error.
我嘗試設置此選項:
mysqli_options($cnx, MYSQLI_OPT_LOCAL_INFILE, 1);
在我的加載數據調用之前,但仍然沒有效果.
prior to my load data call, but still no-effect.
我該如何解決這個問題?
How do I correct this problem?
推薦答案
有幾件事可能是錯誤的.請嘗試以下操作:
There are a couple things that could be wrong. Try the following:
添加到您的 my.cnf:
[mysql]
local-infile=1
[mysqld]
local-infile=1
從 PHP 連接時啟用本地 infile
$conn = mysqli_init();
mysqli_options($conn, MYSQLI_OPT_LOCAL_INFILE, true);
mysqli_real_connect($conn,server,user,code,database);
這篇關于“加載數據本地 infile"不允許命令的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!