title: mysqldump table per *.sql file batch script
body: <p>I have done some digging around and I can not find a way to make mysqldump create a file per table. I have about 100 tables (and growing) that I would like to be dumped into separate files without having to write a new mysqldump line for each table I have.</p>
  
  <p>E.g. instead of my_huge_database_file.sql which contains all the tables for my DB.
  I'd like mytable1.sql, mytable2.sql etc etc</p>
  
  <p>Does mysqldump have a parameter for this or can it be done with a batch file? If so how.</p>
  
  <hr>
  
  <p>It is for backup purposes.</p>
  
  <p>I think I may have found a work around, and that is to make a small PHP script that fetches the names of my tables and runs mysqldump using exec().</p>
  
  <pre><code>$result = $dbh-&gt;query("SHOW TABLES FROM mydb") ;
  
  while($row = $result-&gt;fetch()) {
  
  exec('c:\Xit\xampp\mysql\bin\mysqldump.exe -uroot -ppw mydb &gt; c:\dump\\'.$row[0]) ;
  }
  </code></pre>
  
  <p>In my batch file I then simply do:</p>
  
  <pre><code>php mybackupscript.php
  </code></pre>