title: Mysql Can't create/write to file error#13
body: <p>I had created a Django view which is returning some data after reading from MySql DB.When i try and fetch around 6000 rows from the Database,everything works fine and the view returns HttpResponse as is expected.However as i try to fetch 7000+ rows i get the following error 
  <br/></p>
  
  <pre><code>(1, "Can't create/write to file '/home/nipun/mysql_temp/MYzplJok' (Errcode: 13)")
  </code></pre>
  
  <p><br/>
  Earlier i thought that the error could be due to space getting exhausted for /temp,so i changed the tempdir setting in my.cnf 
  <br/>
  I also ensured that new tmpdir /home/nipun/mysql_temp and it's parent directories are writable by me by changing the ownership.
  Although this is not a Django problem,here is the view
  <br/></p>
  
  <pre><code>def query_json(request):
      from django.utils import simplejson
      objects=Publisher.objects.filter(location='ROOM_01',sensor_name='CPU_TEMPERATURE').order_by('-id')[0:9000]
  
      json = simplejson.dumps( [{"reading": float(o.reading),
                             "timestamp": str(o.timestamp)
                         } for o in objects] )
  
      return HttpResponse(json,mimetype="application/json")
  </code></pre>
  
  <p><br/></p>
  
  <p>So in the filter changing 9000 to 6000 works fine.
  <br/>
  Some more information about the error is provided in the Django stack trace
  <br/></p>
  
  <pre><code>errorclass  
  &lt;class '_mysql_exceptions.InternalError'&gt;
  errorvalue  
  InternalError(1, "Can't create/write to file '/home/nipun/mysql_temp/MYuotga9' (Errcode:     13)")
  error   
  (&lt;class '_mysql_exceptions.InternalError'&gt;,
  InternalError(1, "Can't create/write to file '/home/nipun/mysql_temp/MYuotga9' (Errcode: 13)"))
  </code></pre>
  
  <p><b>EDIT</b>
  <br/>
  As per a comment, i tried this on my MySQL prompt <br/></p>
  
  <pre><code>mysql&gt; CREATE TEMPORARY TABLE t (i int);
  ERROR 1005 (HY000): Can't create table 't' (errno: 13)
  </code></pre>
  
  <p>So it essentially is now an issue of how to allow MySQL to write to temporary directory</p>