MySql is unable to find file in same directory?
<p>I'm trying to load a picture into a mysql database with the following code:</p>

<pre><code>cursor, db = get_db()
cursor.execute("UPDATE People SET photo = LOAD_FILE(\'myphoto.jpg\')")
cursor.close()
db.commit()
db.close()
</code></pre>

<p>I've been able to set photo to other values by replacing the <code>LOAD_FILE</code> phrase with something simpler, so I know that the problem stems from loading the picture.  Meanwhile, myphoto.jpg is located in the directory that the code is being run from.  MySql executes these commands without complaining, but does not actually put the picture in the db.  What could be going wrong and how can I fix it?</p>

<p>Operating system is linux.</p>

<p>Check whether the file is loaded into the mysql or not.</p>

<pre><code>select load_file('/currentdir/file.blob')
+-----------------------------+
| load_file('currentdir/file.blob') |
+-----------------------------+
| NULL                        |
+-----------------------------+
</code></pre>

<p>This could be beccause of user permissions.</p>

<pre><code>sudo chown mysql:mysql /currentdir/file.blob
</code></pre>

<blockquote>
  <p>I also read <a href="https://bugs.mysql.com/bug.php?id=38403" rel="nofollow">here</a>, that there is bug on linux, that this problem could
  be because of <code>apparmor</code>, disabling it might solve the problem, do
  this <code>/etc/init.d/apparmor stop</code> on ubuntu.</p>
</blockquote>

<p>Other Possible reasons!!</p>

<ol>
<li><p>Check for the path</p></li>
<li><p>Check for the privileges</p></li>
<li><p>Does the functions return NULL</p></li>
<li><p>Try this <a href="http://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_load-file" rel="nofollow">query</a></p></li>
<li><p>Is the instance of mysql is on your machine now?</p></li>
</ol>

<p>And also in linux you dont have to place back slashes, <code>LOAD_FILE(\'myphoto.jpg\')</code>, try without them, <code>LOAD_FILE('myphoto.jpg')</code></p>

python mysql file