Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I tried adding lines to my.cnf

[mysql]
infile = 1
[mysqld]
infile = 1

SHOW VARIABLES LIKE "%infile" displays true in mysql.

But LOAD DATA does not work. I tried it in a PHP script and in phpMyAdmin.

It only works if I start mysql from the command line with the --allow-infile flag

mysql --local-infile -u root -p db_name

But this did not solve the PHP problem.

share|improve this question

3 Answers 3

up vote 1 down vote accepted

I finally solved the issue in what seems like a ridiculously simple way. I've seen so many posts regarding this problem but the only solution I found that worked was one that was somewhat hidden in a stackoverflow post. It turns out the issue can be solved at connect time (which makes sense):

mysql_connect(HOST,USER,PASS,false,128);

The answer is right there on the manual page, it turns out.

The only thing I still don't understand is why this is necessary on my new Ubuntu install but has never been a problem on any other system, Ubuntu or CentOS.

I should also add that the above method is probably more portable than other methods, since you are setting the connection type in the code rather than in a config file.

share|improve this answer

There is an option for allowing the LOAD DATA LOCAL INFILE query in /etc/my.cnf:

local-infile = 1

Remember to restart MySQL after applying the change.

share|improve this answer
    
Does not work, even after restart. See my own answer to my question for how I eventually solved it. Your solution may work for some people, though. –  Buttle Butkus Nov 25 '12 at 9:39
1  
According to the MySQL manual, LOCAL INFILE must be enabled on the server AND the client connecting to it. So it wouldn't suffice to just turn it on on the server, you would also have to enable it (as you did) on the client. –  Panagiotis PJ Papadomitsos Nov 25 '12 at 12:01

For Ubuntu users i've found the solution. This problem is related to AppArmor MySQL LOAD DATA INFILE - AppArmor issue

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.