mysql load data infile can't get stat of file Errcode: 2

try to use LOAD DATA LOCAL INFILE instead of LOAD DATA INFILE

otherwise check if apparmor is active for your directory


I had a similar problem. The resolution was a mildly ugly hack, but much easier to remember than apparmor workarounds provided that you can 'sudo'. First, I had to put the input file in the mysql sub-directory for the database I was using:

sudo cp myfile.txt /var/lib/mysql/mydatabasename

This does a copy and leaves 'root' as the file owner. After getting into mysql and doing a USE mydatabasename, I was able to populate appropriate table using

LOAD DATA INFILE 'mytabdelimitedtextfile.txt' INTO TABLE mytablename;

Using --local parameter will help with this.

Example: mysqlimport --local databasename file.txt -p

source: http://dev.mysql.com/doc/refman/5.1/en/load-data.html "The --local option causes mysqlimport to read data files from the client host"