MySQL import file data error: HY000: file ' xxx.txt ' not Found (errcode:13)

Source: Internet
Author: User
Tags mysql import

Suddenly encountered MySQL Error: Error (HY000): File '/var/www/xiaoyou/static/upload/import/20130427105733.csv.txt ' not Found (Errcode: 13)

Feel strange, because the program in the local very OK, angry statement as follows:

LOAD DATA INFILE '/var/www/upload/abc.csv.txt ' into TABLE alumni_import fields TERMINATED by ', ' optionally enclosed by ' " ' LINES TERMINATED by ' IGNORE 1 LINES (field1,field2,...);

I have been because of the permissions, problems, but when I put the directory and file permissions are chmod to 777 or error, after Google found:


Recent Ubuntu Server Editions (such as 10.04) ship with AppArmor and MySQL's profile might is in enforcing mode by default . You can check the this by executing
sudo aa-status
Like so:


# sudo aa-status 5 profiles is Loaded.5 profiles is 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 is in complain mode.1 Processes has profiles Defined.1 processes is in enforce mode:/usr/sbin/mysqld (1089) 0 processes is in complain mode.

If Mysqld is included in 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 are can do is edit
/etc/apparmor.d/usr.sbin.mysqld
and add
/data/
and
/data/*
Near the bottom:

...
/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


The general content is, mysqld forced encoding, the file does not have write permission, so I add the file directory to mysqld (/etc/apparmor.d/usr.sbin.mysqld the bottom of this file, such as the bold part):


/VAR/WWW/UPLOAD/IMPORT/R,


/var/www/upload/import/* RW,

MySQL import file data error: HY000: file ' xxx.txt ' not Found (errcode:13)

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.