theblackpost
theblackpost

Reputation: 158

Can't create/write to file MYSQL to directory different of /var/tmp

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

Upvotes: 0

Views: 862

Answers (3)

Gordan Bobić
Gordan Bobić

Reputation: 1858

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.

Upvotes: 0

theblackpost
theblackpost

Reputation: 158

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.

Upvotes: 0

Andi S.
Andi S.

Reputation: 339

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

secure_file_priv

Upvotes: 1

Related Questions