load_file() problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • stacy2939287
    New Member
    • Nov 2009
    • 1

    load_file() problem

    I'm running as mysql root user on my system.

    I can select load_file('/etc/passwd'); no problem

    But when I try to select load_file('/var/lib/mysql/mysql'); I get NULL as a result why? this file is good, I can cat it as root and view the mysql user data, why cant mysql load_file it? Its permissions are the default:

    -rw-rw---- 1 mysql mysql 444 2009-08-04 19:08 user.MYD

    It's owner is by default the user mysql and has read permission, so why doesn't mysql like to load_file it? Is mysql somehow blocking access to this file and if so how can I bypass that? Doing stuff like mysql/../mysql in the path doesn't work, and using hex encoding didn't work either?
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hey.

    You say you are trying to load a file called "/var/lib/mysql/mysql" but your ls output lists a file named "user.MYD". Could you simply have typed in the wrong path?

    If not, consider this, from the manual:
    The file must be readable by all and its size less than max_allowed_pac ket bytes.
    It says "readable by all". Perhaps you need to CHMOD the file to 664? (Or otherwise readable by everybody.)

    The max_allowed_pac ket directive could of course also be messing with your code. Worth checking.

    Comment

    • mlavannis
      New Member
      • Apr 2010
      • 1

      #3
      You need to grant the MySQL FILE privilege to the user. Note that this is a GLOBAL permission. It allows the user to access all files that MySQL has permissions to.

      You can set it with the command:

      GRANT FILE ON *.* TO person@'<host>' ;
      Last edited by mlavannis; Apr 5 '10, 12:09 AM. Reason: typo

      Comment

      Working...