简体   繁体   English

PHP MySQL使用的命令不允许

[英]PHP MySQL used command not allowed

I'm trying to use the LOAD DATA LOCAL INFILE command in MySQL, but I keep getting an error in PHP/Joomla stating: The used command is not allowed with this MySQL version 我正在尝试在MySQL中使用LOAD DATA LOCAL INFILE命令,但在PHP / Joomla中仍然出现错误,指出:此MySQL版本不允许使用的命令

I've spent quite a while Googling around, but the only suggestions I've seen involve adding local-infile = 1 to my my.cnf file (which I've already done, in [client], [mysql], and [mysqld]). 我花了很多时间在Google上搜索,但我看到的唯一建议是在my.cnf文件中添加local-infile = 1(我已经在[client],[mysql]和[的mysqld])。

Additionally, if I connect from my Apache server to the MySQL server from the command line (so not using PHP), I can run LOAD DATA LOCAL without issue (so it can't be a permissions thing). 另外,如果我从命令行从Apache服务器连接到MySQL服务器(因此不使用PHP),则可以毫无问题地运行LOAD DATA LOCAL(因此它不是权限)。

I've also checked php.ini, and sure enough, mysqli.allow_local_infile is set to 'On'. 我还检查了php.ini,并且确实将mysqli.allow_local_infile设置为“ On”。

Am I missing something here? 我在这里想念什么吗? Do you have to do something special in Joomla to make this work correctly? 您是否需要在Joomla中做一些特殊的事情才能使其正常工作?

I just answered a similar question here , maybe it can help: 我在这里回答了类似的问题,也许可以帮上忙:

After going from MySQL 5.0 to 5.5 I found out that I suddenly have to enable LOCAL INFILE specifically when creating the connection in PHP. 从MySQL 5.0升级到5.5之后,我发现我突然不得不在使用PHP创建连接时专门启用LOCAL INFILE。

Using mysql: 使用mysql:

mysql_connect(server,user,code,false,128); // 128 enables LOCAL INFILE
mysql_select_db(database);

Using mysqli: 使用mysqli:

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

I ran into the same problem, in my case it was the Joomla user lacking privileges that root has; 我遇到了同样的问题,我的情况是Joomla用户缺少root拥有的特权; giving the full privileges to the J user solved it, but then my component is for distribution so I changed to using standard .sql file and parsing / creating them manually. 向J用户授予完全特权可以解决该问题,但是我的组件用于分发,因此我改为使用标准.sql文件并手动解析/创建它们。 Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM