title: Disabling foreign key checks on the command line
body: <p>I have a backup script for my MySQL database, using <code>mysqldump</code> with the <code>--tab</code> option so it produces a <code>.sql</code> file for the structure and a <code>.txt</code> file (pipe-separated) for the content.</p>
  
  <p>Some tables have foreign keys, so when I import it I'm getting the error:</p>
  
  <blockquote>
    <p>ERROR 1217 (23000) at line 8: Cannot delete or update a parent row: a foreign key constraint fails</p>
  </blockquote>
  
  <p>I know about using <code>SET FOREIGN_KEY_CHECKS=0</code> (and <code>SET FOREIGN_KEY_CHECKS=1</code> afterward). If I add those to each <code>.sql</code> file then the import works. But then obviously on the next <code>mysqldump</code> those get overwritten.</p>
  
  <p>I also tried running it as a separate command, like below but the error comes back:</p>
  
  <pre><code>echo "SET FOREIGN_KEY_CHECKS=0" | mysql [user/pass/database] 
  [all the imports]
  echo "SET FOREIGN_KEY_CHECKS=1" | mysql [user/pass/database] 
  </code></pre>
  
  <p>Is there some other way to disable FK checks on the command line?</p>