LOAD DATA INFILE and FILE Permissions on MySQL

I ran into an issue running the LOAD DATA INFILE command from a PHP script the other day. When I logged in as ROOT and executed the script on MySQL Query Browser it worked like a charm. However, when I executed the script from PHP as another use with only SELECT, INSERT, UPDATE and DELETE premission the script failed saying the user does not have enough rights to perform the operation. According to the documentation if the client and server are on the same machine you use the LOAD DATA INFILE form to bulk insert data. However this requires that FILE permission be granted to the user, which is obviously a possible security risk. There does exists a simple work around to this however use the following form of the statement:

LOAD DATA LOCAL INFILE …

This form of the statement should be used when the client and server exists on different machines but works just as well if they are on the same machine and removes the need for the FILE permission.

Share this post:
  • Print
  • email
  • Facebook
  • Twitter
  • Tumblr
  • del.icio.us
  • Digg
  • Reddit
  • Sphinn

Related Posts

This entry was posted in Databases, MySQL and tagged , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.
blog comments powered by Disqus
  • Subscribe to my feed Subscriber via Email Follow Me on Twitter! Check me out on Facebook! Check me out on LinkedIn!