Mysql file export error "ERROR 1(HY000): Can’t create/write to file"

Asked

Viewed 83 times

0

Hello, I was having some problems to export a table in csv format from my database in Mysql due to the definitions of "secure_file_priv"... I made the following changes:

I created a directory at the root and gave permissions: sudo mkdir /mysqlfiles sudo chown -R mysql:mysql /mysqlfiles/

When I give the command in the '''SHOW VARIABLES LIKE' database "secure_file_priv";', the return is:

+------------------+--------------+

| Variable_name | Value |

+------------------+--------------+

| secure_file_priv | /mysqlfiles/ |

+------------------+--------------+

1 Row in set (0.00 sec)

So far, ok. When I try to export something with the " SELECT * FROM name_da_table into outfile '/mysqlfiles/filename';" the return is:

ERROR 1 (HY000): Can’t create/write to file '/conseguiu.txt' (OS Errno 13 - Permission denied)

I was performing several tests, at one point I was able to export the file without major problems, now it seems that it is not allowed to write in the directory to which I gave the export permission.

PS: I’ve tried creating out-of-root directories, and changing permissions to "chmod 777", logging in as root but nothing worked. Even, if the directory permissions are like "chmod 777" mysql does not even go up the service because I am pointing the export to a directory that apparently does not fit the security policies of the service.

  • try exporting the file to the folder /tmp/ if you succeed, it is permission problem if not, you have to see the Grants

  • Hello, for /tmp/ I can yes, I had checked it. For another directory Mysql does not allow exporting?

  • See how the folder permissions are /var/lib/mysql/ and assign the same permissions, as this folder is managed by mysql, just replicate permissions

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.