Server version: 5.7.29-0ubuntu0.18.04.1 (Ubuntu)
I am trying to save output to file: /var/www/dir/file.csv
It gives me an error: Can’t create/write to file ‘/var/www/dir/file.csv’ (Errcode: 13 – Permission denied)
It is PHP script, executing through browser.
Permissions: /dir/ (ls -al)
drwxrwxrwx 2 mysql root 4096 Apr 29 10:40 dir
3
Answers
I have found that default dir to upload files is:
/var/lib/mysql-files/
SHOW VARIABLES LIKE "secure_file_priv";
And rewrite script to write in that directory.
I think you have set this option in your MySQL-Server:
secure_file_priv
As mentioned above, you need to adjust secure_file_priv variable, but you will also need to adjust your AppArmor configuration on Ubuntu (SELinux if it was Fedora/CentOS/RedHat) to allow you to write to the directory outside of the ones already allowed.