title: MySQL LOAD_FILE returns NULL
body: <p>I want to get SQL <em>LOAD_FILE</em> function to work and have read every single question/answer + documentation about this, but here is what's been happening.</p>
  
  <p>When I want to <em>LOAD_FILE</em> from my home directory:</p>
  
  <pre><code>mysql&gt; SELECT LOAD_FILE('/home/myuser/somefile.txt');
  +----------------------------+
  | LOAD_FILE('/home/myuser/somefile.txt') |
  +----------------------------+
  | NULL                       |
  +----------------------------+
  1 row in set (0.00 sec)
  </code></pre>
  
  <p>So after getting this, I thought maybe the problem is that MySQL cannot access my home directory. And I tried running this, which worked fine:</p>
  
  <pre><code>SELECT LOAD_FILE('/etc/mysql/my.cnf');
  </code></pre>
  
  <p>Then <code>SELECT LOAD_FILE('/etc/passwd');</code> worked fine as well.</p>
  
  <p>So I said gotcha, it's a file/folder read/ownership permission problem. So, I moved my file into /etc/mysql/ but then it still didn't work. I've tried <code>chown mysql:mysql somefile.txt</code> but still, I had no luck:</p>
  
  <pre><code>mysql&gt; SELECT LOAD_FILE('/etc/mysql/somefile.txt');
  +----------------------------+
  | LOAD_FILE('/etc/mysql/somefile.txt') |
  +----------------------------+
  | NULL                       |
  +----------------------------+
  1 row in set (0.00 sec)
  </code></pre>
  
  <p>P.S.
  <strong>1.</strong> All files are readable by all user groups, so no need to chmod. But I've even tried <em>chmod 777</em> if you'd like to ask.
  <strong>2.</strong> I checked, secure-file-priv variable is not set up in MySQL, so no, LOAD_FILE is not restricted to any path.</p>
  
  <p>Any ideas what might be the problem here?</p>