title: mysql restore to different database
body: <p>I back up my production database with the following command:</p>
  
  <pre><code>mysqldump -u root --opt --skip-extended-insert --databases my_production_db
  </code></pre>
  
  <p>The resulting dump file has the following lines near the top:</p>
  
  <pre><code>CREATE DATABASE /*!32312 IF NOT EXISTS*/ `my_production_db` /*!40100 DEFAULT CHARACTER SET latin1 */;
  USE `my_production_db `;
  </code></pre>
  
  <p>In order to restore the database to a different destination ie. <code>my_debvelopment_db</code> I have to open the dump file and edit the bits where the database is named.</p>
  
  <p>Then I run:</p>
  
  <pre><code>mysql -u root  -p &lt;password&gt; &lt; mydumpfile
  </code></pre>
  
  <p>I have not figured out another way to do it. </p>
  
  <p>As the database gets bigger this becomes impractical.</p>
  
  <p>Am I missing something? Cant I somehow specify where I want to restore the database? Would I need a different backup command?</p>