Load Data Infile

Logaholic needs the Mysql Load Data Infile method to increase the efficiency of importing your data.
If this method is not working on your installation please check the following:

  • Mysql version >= 5.1
  • The Mysql Variable 'local_infile' must set to 'ON'
  • Check your my.cnf / my.ini
  • Mysql FILE privilege

How To Check Mysql Global Variables

Please open your Mysql command shell and execute the following query:

SHOW GLOBAL VARIABLES LIKE ‘local_infile’

The result we want to see is this:

Variable_name Value
local_infile ON

Check your my.cnf / my.ini
Please check the my.cnf file to see if the correct setting is activated.

On Windows: my.ini
On Linux: my.cnf

Search for the following setting:

local-infile

If you can’t find this please add this line or set it to:

[mysqld] 
local-infile=1

Then restart Mysql.

Mysql FILE privilege
Your Mysql user must have privilege to use file related queries.

To grant FILE privilege to a Mysql user you can run he following command from your Mysql command shell:

GRANT FILE ON *.* TO ‘user’@’localhost’;

Still Having Problems?

If the LOAD DATA INFILE is still not working, try the following:

  • update to the latest PHP version or use the mysqli client
  • and/or disable in your php configuration php.ini the options open_basedir and safe_mode. Restart webserver.
  • check that the request isn’t blocked by apparmor or any other security-software when accessing this folder.

If you are using Ubuntu

  • 1. If you have Ubuntu, you can simply disable AppAprmor.

sudo /etc/init.d/apparmor kill
sudo update-rc.d -f apparmor remove

  • 2. But this is not the best way to solve the problem. It is best to set up a AppArmor profile for mysql.

You just need to add a line to AppAprmor profile to enable reading-writing in the required directory. For example:

/var/www/mysite/** rw,

And then restart AppArmor by this cmd:

/etc/init.d/apparmor stop
/etc/init.d/apparmor start

  • 3. Third way to solve this issue - disabling MySQL AppArmor profile:

sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld