SELECT INTO OUTFILE permission denied but the user can write to the directory
This may be caused by mysql user permissions.
As stated here https://dba.stackexchange.com/questions/17029/cannot-output-mysql-data-to-file
To give yourself FILE privilege, do the following:
service mysql restart --skip-networking --skip-grant-tables
mysql <hit enter>
UPDATE mysql.user SET File_priv = 'Y' WHERE user='lea' AND host='localhost';
exit
service mysql restart
The linux user can write a file. But the mysql service may be blocked by apparmor.
Check this file: /etc/apparmor.d/usr.sbin.mysqld
.
Add your project folder there:
/usr/sbin/mysqld {
[...]
/home/datam/xfers/online/ r,
/home/datam/xfers/online/* rw
[...]
}
Finally, do a
sudo /etc/init.d/apparmor reload
On modern systems mariaDB & mysql gets installed with systemd support. Among other things, it has this setting in /etc/systemd/system/mysql.service:
Prevent accessing /home, /root and /run/user
ProtectHome=true
That's what stops it from writing in /home.