0

Using Ubuntu Server 14.04 x64 / PHP 5.5.9-1ubuntu4 (cli) w/ FPM / MySQL InnoDB version 5.5.35

I've created a PHP script that downloads a text file from a remote server and then attempts to import it with the LOAD DATA LOCAL INFILE '/path/to/file.txt' INTO TABLE test FIELDS TERMINATED BY '\n'.

I've gone through the process of modifying the php.ini file:

[MySQL]
; Allow accessing, from PHP's perspective, local files with LOAD DATA statements
; http://php.net/mysql.allow_local_infile
mysql.allow_local_infile = On

I've modified my.cnf (both [mysql] and [mysqld] entries):

local-infile=1
local-infile

I've run MySQL from the terminal and then issue:

SET GLOBAL local_infile = 'ON';

I've manually started and stopped MySQL with:

sudo /etc/init.d/mysql start --enable-local-infile

After each of these commands I can run SHOW GLOBAL VARIABLES LIKE 'local_infile'; and it always says the value is ON. I have no problem whatsoever executing my LOAD DATA command from MySQL prompt but if I try to run the LOAD DATA stored in a PHP file it errors out with:

The used command is not allowed with this MySQL version

From what I've read, there seems to be a few who suggest to recompile PHP with "--with-mysql=/usr" but that seems like a real sledge hammer approach to me, maybe I'm wrong. I can issue ANY MySQL query except for that that from a PHP file. What am I doing wrong?

sparecycle
  • 2,038
  • 5
  • 31
  • 58
  • http://stackoverflow.com/questions/7638090/load-data-local-infile-forbidden-in-php ? – Marc B Jul 07 '14 at 19:20
  • possible duplicate of [LOAD DATA LOCAL INFILE does not work from php 5.5 using PDO](http://stackoverflow.com/questions/20226631/load-data-local-infile-does-not-work-from-php-5-5-using-pdo) – Michael Hampton Jul 07 '14 at 20:15

1 Answers1

0

You have to write twice the following line into the file /etc/mysql/my.cnf

sudo gedit /etc/mysql/my.cnf

then under paragraph [mysql] and paragraph [mysqld]

add the following line :

local-infile=1

then save the file

then restart

Gynteniuxas
  • 7,035
  • 18
  • 38
  • 54
solo
  • 1