A MySQL error was suddenly encountered: Error (HY000): File '/var/www/xiaoyou/static/upload/import/20130427105733.csv.txt ' not Found (Errcode: 13)
The feeling is very strange, because the program in the local very OK, angry statement as follows:
LOAD DATA INFILE '/var/www/upload/abc.csv.txt ' into the TABLE alumni_import FIELDS terminated by ', ' optionally enclosed by ' ' ' LINES terminated by ' IGNORE 1 LINES (field1,field2,...);
I have always been because of the permissions, the problem, but when I put the directory and file permissions are chmod 777 after the error, Google found that:
Recent Ubuntu Server Editions (such as 10.04) ship with AppArmor and MySQL's profile might is in enforcing mode by default . Can check this by executing
sudo aa-status
Like so:
# sudo aa-status 5 profiles are Loaded.5 profiles are in enforce MODE./USR/LIB/CONNMAN/SCRIPTS/DHCLIENT-SCRIPT/SBIN/DHCLI Ent3/usr/sbin/tcpdump/usr/lib/networkmanager/nm-dhcp-client.action/usr/sbin/mysqld 0 profiles are in complain mode.1 Processes have profiles Defined.1 processes are in enforce mode:/usr/sbin/mysqld (1089) 0 processes are in complain mode.
If Mysqld is included into enforce mode, then it is the one probably denying the write. Entries would also is written in
/var/log/messages
When AppArmor blocks the writes/accesses. What You can does is edit
/etc/apparmor.d/usr.sbin.mysqld
and add
/data/
and
/data/*
Near the bottom like so:
...
/usr/sbin/mysqld {
...
/VAR/LOG/MYSQL/R,
/var/log/mysql/* RW,
/var/run/mysqld/mysqld.pid W,
/var/run/mysqld/mysqld.sock W,
/DATA/R,
/data/* RW,
}
And then make AppArmor reload the profiles.
# Sudo/etc/init.d/apparmor Reload
In general, Mysqld is forced to encode and the file does not have write permission, so I add the file directory to the mysqld (/etc/apparmor.d/usr.sbin.mysqld the bottom of this file, as in the Bold section):
/var/www/upload/import/r,
/var/www/upload/import/* RW,