Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FILE privilege to MySQL session/user

When someone is registerd in my MySQL database, this function must work:

mysql_query("SELECT mail 
               FROM users 
               INTO OUTFILE 'test.txt'");

But I get the error

Access denied for user 'registerdb'@'%' (using password: YES)

So how I give the FILE writing permission to the session/user?

like image 369
Francis Michels Avatar asked Dec 12 '22 09:12

Francis Michels


1 Answers

Chek for permissions of that user:

SHOW GRANTS FOR 'registerdb'@'%'

If there no listed FILE permission, just add it:

GRANT FILE ON . to 'registerdb'@'%'

and then:

FLUSH PRIVILEGES;

But beware for by doing granting the FILE permission on *.* you are essentially giving that user full access to any file the server.

To limit limit the location in which files can be read and written, set the secure_file_priv system to a specific directory.

like image 165
Ferrel Navia Avatar answered Dec 27 '22 23:12

Ferrel Navia