title: MySQL OUTFILE query complains that "file already exists" but the file does not exist at all
body: <p>I am writing a very simple shell script to dump a table into CSV file. Here is part of it:</p>
  
  <pre><code>day=`/bin/date +'%Y-%m-%d'`
  file="/tmp/table-$day.csv"
  rm $file
  query="SELECT * FROM table INTO OUTFILE '$file' FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\\n'"
  echo "$query" | mysql &lt;connection_parameters&gt;
  </code></pre>
  
  <p>I put in <code>rm $file</code> to make sure that the file does not exist prior to the query's execution.</p>
  
  <p>However, when I execute the script, I get conflicting messages:</p>
  
  <pre><code>rm: cannot remove `/tmp/table-2013-02-08.csv': No such file or directory
  ERROR 1086 (HY000) at line 1: File '/tmp/table-2013-02-08.csv' already exists
  </code></pre>
  
  <p>I cannot find the OUTFILE anywhere in the machine.</p>
  
  <p>So what is wrong.. ?</p>
  
  <p>Thank you.</p>