MySQL on Ubuntu cannot “load data infile”
“load data infile” imports were failing when running MySQL on Ubuntu 12.04.2 LTS because MySQL was unable to read the file.
AppArmour was preventing mysqld reading the file. This can be checked using aa-status:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
$ sudo aa-status apparmor module is loaded. 7 profiles are loaded. 7 profiles are in enforce mode. /sbin/dhclient /usr/lib/NetworkManager/nm-dhcp-client.action /usr/lib/connman/scripts/dhclient-script /usr/lib/cups/backend/cups-pdf /usr/sbin/cupsd /usr/sbin/mysqld /usr/sbin/tcpdump 0 profiles are in complain mode. 2 processes have profiles defined. 2 processes are in enforce mode. /usr/sbin/cupsd (782) /usr/sbin/mysqld (1178) 0 processes are in complain mode. 0 processes are unconfined but have a profile defined. |
Note that mysqld is listed as being in enforce mode.
To allow access to files in a praticular directory, add entries to /etc/apparmor.d/usr.sbin.mysqld EG:
1 2 |
/var/www/appdir/tmp/ r, /var/www/appdir/tmp/* rw, |
and make AppArmour reload its profiles:
1 |
$ sudo /etc/init.d/apparmor reload |