quot;Load data local infilequot; command not allowed(“加载数据本地 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"不允许命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:“加载数据本地 infile"不允许命令
基础教程推荐
- 在PHP中根据W3C规范Unicode 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 如何替换eregi() 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
