While using the "LOAD DATA INFILE" facility, a common error is -
"ERROR 29 (HY000): File '/mydir/myfile.txt' not found (Errcode: 13)"
Here is the more proper solution to this issue (other shortcuts exist) -
Use apparmor to indicate which resources (files) mysql can use.
Step a:
sudo vi /etc/apparmor.d/usr.sbin.mysqld
Step b: Add the lines highlighted in blue
/usr/sbin/mysqld {
#include <abstractions/base>
/etc/mysql/conf.d/ r,
/etc/mysql/conf.d/* r,
/etc/mysql/*.cnf r,
/usr/lib/mysql/plugin/ r,"
/usr/lib/mysql/plugin/*.so* mr,
/usr/sbin/mysqld mr,
/usr/share/mysql/** r,
/var/log/mysql.log rw,
/var/log/mysql.err rw,
/var/lib/mysql/ r,
/var/lib/mysql/** rwk,
/var/log/mysql/ r,
/var/log/mysql/* rw,
/mydir/ r, # this line gives read permission to the mydir directory
/mydir/* rw, # this line gives read,write permission to all the files in mydir
#include <abstractions/base>
/etc/mysql/conf.d/ r,
/etc/mysql/conf.d/* r,
/etc/mysql/*.cnf r,
/usr/lib/mysql/plugin/ r,"
/usr/lib/mysql/plugin/*.so* mr,
/usr/sbin/mysqld mr,
/usr/share/mysql/** r,
/var/log/mysql.log rw,
/var/log/mysql.err rw,
/var/lib/mysql/ r,
/var/lib/mysql/** rwk,
/var/log/mysql/ r,
/var/log/mysql/* rw,
/mydir/ r, # this line gives read permission to the mydir directory
/mydir/* rw, # this line gives read,write permission to all the files in mydir
Step 3:
sudo /etc/init.d/apparmor reload
No comments:
Post a Comment