我有一个 PHP 脚本,它调用 MySQL 的 LOAD DATA INFILE
从 CSV 文件加载数据.但是,在生产服务器上,我最终出现了以下错误:
I have a PHP script that calls MySQL's LOAD DATA INFILE
to load data from CSV files. However, on production server, I ended up with the following error:
用户拒绝访问...(使用密码:是)
Access denied for user ... (using password: yes)
作为一个快速的解决方法,我将命令更改为 LOAD DATA LOCAL INFILE
,它起作用了.但是,相同的命令在客户端的服务器上失败并显示以下消息:
As a quick workaround, I changed the command to LOAD DATA LOCAL INFILE
which worked. However, the same command failed on client's server with this message:
此 MySQL 版本不允许使用的命令
The used command is not allowed with this MySQL version
我认为这与服务器变量有关:local_infile = off
如此处所述一>.
I assume this has something to do with the server variable: local_infile = off
as described here.
请提出不涉及更改服务器设置的解决方法.请注意,安装在同一台服务器上的 phpMyAdmin 实用程序似乎接受 CSV 文件,但我不确定它是否使用 LOAD DATA (LOCAL) INFILE
.
Please suggest a workaround that does not involve changing server settings. Note that phpMyAdmin utility installed on the same server appears to accept CSV files though I am not sure it it uses LOAD DATA (LOCAL) INFILE
.
遇到和 root 一样的问题,把我扔了一会儿
Ran into the same issue as root and threw me for a moment
可能是你的服务器设置有问题 compile
could be an issue with your server settings set with compile
使用同一用户测试登录控制台并尝试加载数据命令
to test login to console with the same user and try your load data command
如果出现同样的错误,请尝试关闭控制台并运行
if you get the same error, try closing console and running
mysql -u USER -p --local-infile=1 DATABASE
现在尝试再次运行加载数据命令
now try running load data command again
如果它有效,那么您将需要使用命令行选项重新启动 mysqld 或使用配置选项重新安装
if it works then you're going to need to restart mysqld with command line option or re-install with configuration option
参考文献(参考文献适用于 5.0,但适用于 5.5):
references (references are for 5.0 but worked for me with 5.5):
http://dev.mysql.com/doc/refman/5.0/en/load-data-local.html
http://dev.mysql.com/doc/refman/5.0/en/mysql-command-options.html#option_mysql_local-infile
这篇关于LOAD DATA LOCAL INFILE 给出错误 The used command is not allowed with this MySQL version的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!