Providing access to the database database folder

I am trying to create an export of csv data from mysql using the following query:

SELECT * INTO OUTFILE '/tmp/result.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\n'
FROM getfreepellets WHERE 1

And I get the following error:

#1045 - Access denied for user '[username]'@'localhost' (using password: YES)

(username removed but correct)

How can I provide access to this user to create a file on the server?

Edit:

I changed the first line to be my exact home path, and got the same error.

+3
source share
1 answer

You can privilege GRANTyour user FILE:

The provision FILEgives you the right to read and write files on the server host using the operators LOAD DATA INFILEand SELECT ... INTO OUTFILEand functions LOAD_FILE().

, FILE, , , MySQL. ( , , .) FILE , MySQL . .

FILE, :

GRANT FILE ON *.* TO 'your_user'@'localhost';
+5

Source: https://habr.com/ru/post/1758546/


All Articles