简体   繁体   English

Mysql LOAD DATA LOCAL INFILE在mysql控制台中有效,但在php脚本中无效

[英]Mysql LOAD DATA LOCAL INFILE works in mysql console but not in php scripts

after a few tweaks I've managed to enable LOAD DATA LOCAL INFILE in my phpmyadmin. 经过一些调整后,我设法在phpmyadmin中启用LOAD DATA LOCAL INFILE。

However, when I try the same query in php scripts, I get "The used command is not allowed with this MySQL version" 但是,当我在php脚本中尝试相同的查询时,得到“此MySQL版本不允许使用的命令”

I already tried removing the "LOCAL" word but it doesn't work in mysql console either then, probably due to permission issues 我已经尝试过删除“ LOCAL”一词,但由于权限问题,它在mysql控制台中也无法正常工作

I've already tried adding "128" at the end of the mysql_connect command, and apparmor is not running on the server so I'm out of ideas.. 我已经尝试在mysql_connect命令的末尾添加“ 128”,并且apparmor没有在服务器上运行,所以我没有主意。

I managed to solve it thus: 我设法解决了这个问题:

  1. grant privileges in mysql 在mysql中授予权限
  2. edit open_basedir settings in order to be able to write in /tmp/ 编辑open_basedir设置,以便能够在/ tmp /中写入
  3. use the /tmp/ folder to store the csv 使用/ tmp /文件夹存储csv
  4. tell mysql to read /tmp/file.csv 告诉mysql读取/tmp/file.csv

For some reasons I couldn't use LOCAL, but this last-resort worked 由于某些原因,我无法使用LOCAL,但是此最后一个方法有效

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

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