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

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

问题描述

我正在使用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.

如何纠正此问题?

推荐答案

有几件事可能是错误的.请尝试以下操作:

There are a couple things that could be wrong. Try the following:

添加到您的my.cnf:

[mysql]
local-infile=1

[mysqld]
local-infile=1

从PHP连接时启用本地文件

$conn = mysqli_init();
mysqli_options($conn, MYSQLI_OPT_LOCAL_INFILE, true);
mysqli_real_connect($conn,server,user,code,database);

这篇关于“加载数据本地文件"不允许的命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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