Bug #1521 load_file privileges not working as documented
Submitted: 10 Oct 2003 9:38 Modified: 10 Oct 2003 21:22
Reporter: Cliff Ingham Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.1.0-alpha OS:Linux (linux)
Assigned to: CPU Architecture:Any

[10 Oct 2003 9:38] Cliff Ingham
Description:
The documentation has that read permissions on the file plus FILE privileges for the user should work.  However, after working with it, I have found out that GRANT ALL PRIVILEGES ON databaseName.* TO user@host  will not allow LOAD_FILE use.  Currently, you must do GRANT ALL PRIVILEGES ON *.* TO user@host.

How to repeat:
Place a text file in /tmp/whatever.  chmod it to 644.
Create the two users - one with database only privileges, and one with *.*:
GRANT ALL PRIVILEGES ON somedatabase.* TO testuser@localhost identified by 'testpass'

log in as that user
do: SELECT LOAD_FILE('/tmp/whatever'); ( Will return NULL )

delete that user, flush privivleges, then add them in again ( or add in another user) with: GRANT ALL PRIVILEGES ON *.* TO testuser@localhost identified by 'testpass'

do: SELECT LOAD_FILE('/tmp/whatever'); ( Will return the contents of the file )

Suggested fix:
Either a documentation clarification or make it so GRANT ALL PRIVILEGES ON databasename.* allows the load_file to work.
[10 Oct 2003 21:22] Paul DuBois
Your GRANT statement grants database-level privileges,
but there is no FILE privilege at that level. FILE is a global
privilege and must be granted with ON *.*.  GRANT ALL
at the database level grants only database-level privileges.

See:
http://www.mysql.com/doc/en/GRANT.html
and
http://www.mysql.com/doc/en/Privileges.html