skip to Main Content

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


  1. Chosen as BEST ANSWER

    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.


  2. I think you have set this option in your MySQL-Server:

    secure_file_priv

    Login or Signup to reply.
  3. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search