Linux/MySQL Permission Problem: ERROR 13 (HY000): Can't get stat


I use Linux (CentOS) to run my web server, and I use MySQL for the database.

I need to do the following from a mysql command line:
         LOAD DATA INFILE '/home/mydir/dump.txt' INTO TABLE my_db.table FIELDS TERMINATED BY '||';

But I get the following error:
        ERROR 13 (HY000): Can't get stat of '/home/mydir/dump.txt' (Errcode: 13)

I think the problem is that MySQL does not have permission to access '/home/mydir/dump.txt'.

I changed both the owner and the group for '/home/mydir/dump.txt' to 'nobody' and I change its permission to 777 but I still get the error!

Please help!
LVL 16
Who is Participating?
WarpsehConnect With a Mentor Commented:
Instead of LOAD DATA INFILE try load data LOCAL infile :)
NopiusConnect With a Mentor Commented:
The difference between LOCAL and not LOCAL is in user id of the loading program.

if LOCAL it's a 'mysql' (typically) user, if not LOCAL it's the owner of the current process (by default 'nobody' if apache, or current user it you are using 'mysql' command line).

So if you load from your mysql command, I agree with Warpseh, use LOCAL.

If you like this command to be working without 'LOCAL', change permissions to your home directory: 'chmod 755 /home/mydir' to be readable by others.
All Courses

From novice to tech pro — start learning today.