title: SELECT INTO OUTFILE permission denied but the user can write to the directory
body: <p>I have an issue trying to use <code>SELECT INTO OUTFILE</code> and using a directory other than <code>/tmp</code>.  </p>
  
  <p>My Linux user is named <code>datam</code>, my MySQL user is <code>lea</code>, and MySQL runs as <code>mysql</code>.</p>
  
  <p>When <code>datam</code> runs <code>mysql -u lea database</code> and tries to do a <code>SELECT INTO OUTFILE</code> with a path of <code>/home/datam/xfers/online/file.csv</code>, I get an error code 13, permission denied.  Using <code>/tmp/file.csv</code> works, so I'm fairly confident it is not an issue with permissions within MySQL.</p>
  
  <p>I've added <code>mysql</code> to the <code>datam</code> group and have verified this with:</p>
  
  <pre><code>~$ sudo id mysql
  uid=106(mysql) gid=114(mysql) groups=114(mysql),1001(datam)
  </code></pre>
  
  <p>I have <code>/home/datam/</code> set as 775 recursively.  </p>
  
  <p>If I do <code>sudo -u mysql /bin/bash</code> and go to <code>/home/datam/xfers/online/</code> and do <code>touch file</code> it writes a file.</p>
  
  <p>What do I need to do to allow <code>mysql</code> to write a file from <code>SELECT INTO OUTFILE</code>?</p>
  
  <p>I believe this is not a duplicate of other questions surrounding this subject, because I've looked at them and followed all of their instructions (setting execute on all directories leading up to the one I want, setting GRANT FILE ON, etc).</p>
  
  <p>MySQL user <code>lea</code> grants:</p>
  
  <pre><code>+-----------------------------------------------------------------------------------------------------------+
  | Grants for lea@localhost                                                                                  |
  +-----------------------------------------------------------------------------------------------------------+
  | GRANT FILE ON *.* TO 'lea'@'localhost' IDENTIFIED BY PASSWORD '*9BB439A3A652A9DAD3718215F77A7AA06108A267' |
  | GRANT ALL PRIVILEGES ON `database`.* TO 'lea'@'localhost'                                    |
  +-----------------------------------------------------------------------------------------------------------+
  </code></pre>