我正在使用 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模板网!
mysql 中的 store_result() 和 get_result() 返回 falsestore_result() and get_result() in mysql returns false(mysql 中的 store_result() 和 get_result() 返回 false)
调用未定义的函数 mysqli_result::num_rows()Call to undefined function mysqli_result::num_rows()(调用未定义的函数 mysqli_result::num_rows())
PHP 准备好的语句问题PHP Prepared Statement Problems(PHP 准备好的语句问题)
mysqli_fetch_array 只返回一个结果mysqli_fetch_array returning only one result(mysqli_fetch_array 只返回一个结果)
PHP MySQLi 多次插入PHP MySQLi Multiple Inserts(PHP MySQLi 多次插入)
如何确保 MySQL 中的值在 PHP 中保持其类型?How do I make sure that values from MySQL keep their type in PHP?(如何确保 MySQL 中的值在 PHP 中保持其类型?)