MySQL Error: Error (HY000): File ' xxx.txt ' not Found (errcode:13)

Source: Internet
Author: User
Tags file permissions

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,

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.