title: MySQL INTO OUTFILE override existing file?
body: <p>I've written a big sql script that creates a CSV file. I want to call a cronjob every night to create a fresh CSV file and have it available on the website.</p>
  
  <p>Say for example I'm store my file in '/home/sites/example.com/www/files/backup.csv'</p>
  
  <p>and my SQL is </p>
  
  <pre><code>SELECT * INTO OUTFILE '/home/sites/example.com/www/files/backup.csv'
    FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
    LINES TERMINATED BY '\n'
    FROM ( ....
  </code></pre>
  
  <p>MySQL gives me an error when the file already exists</p>
  
  <blockquote>
    <p>File '/home/sites/example.com/www/files/backup.csv' already exists</p>
  </blockquote>
  
  <p>Is there a way to make MySQL overwrite the file?</p>
  
  <p>I could have PHP detect if the file exists and delete it before creating it again but it would be more succinct if I can do it directly in MySQL.</p>