title: mysqldump via SSH tunnel
body: <p>I have a server setup as follows:</p>
  
  <ul>
  <li><code>webserver</code> (gateway machine, accessible from the Internet via SSH)</li>
  <li><code>dbserver</code> (database server, <em>not accessible from the web</em>)</li>
  </ul>
  
  <p>My goal is to use <code>mysqldump</code> to pull a backup from <code>dbserver</code> to my laptop via the web.  Up to this point, the question is a duplicate of <a href="https://stackoverflow.com/questions/10322352/i-would-like-to-simplify-ssh-tunneling-to-do-a-mysql-dump-and-scp-the-file-to-lo">this question</a>, <em>except</em> that <code>webserver</code> does <em>not</em> have <code>mysqldump</code> installed, and I don't have the rights to install it.  So I'm trying to use <code>mysqldump</code> on my laptop to pull from a server behind a gateway that I don't have SSH rights to.</p>
  
  <p>Following the discussions <a href="https://serverfault.com/questions/134007/how-to-dump-remote-database-without-mysqldump">here</a> and <a href="https://serverfault.com/questions/36467/temporary-ssh-tunnel-for-backup-purposes">here</a>, I'm trying to do something like this to set up the tunnel:</p>
  
  <pre><code>ssh -f -L 3306:dbserver:3306 user@webserver -N
  </code></pre>
  
  <p>followed by:</p>
  
  <pre><code>mysqldump -P 3306 -h localhost -u dbuser -p db
  </code></pre>
  
  <p>but I run into the same trouble <a href="https://serverfault.com/questions/134007/how-to-dump-remote-database-without-mysqldump">this person</a> did, and am not quite sure what's going on with the tunneling or how to fix it (and adding an entry to my laptop's hosts file doesn't seem to fix it like it did for him).</p>