“加载数据本地 infile"不允许命令 [英] "Load data local infile" command not allowed

查看:26
本文介绍了“加载数据本地 infile"不允许命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 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"不允许命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆