title: python used sshtunnel can't connect to mysql
body: <p>I'm trying to use <code>sshtunnel</code> and <code>MySQLdb</code> in <code>python2.7</code> to tunnel my connection and facing following problem:</p>
  
  <p>I used Sequel Pro to connect mysql was OK, but the python code did not work!</p>
  
  <p>Sequel Pro is like this:</p>
  
  <p><a href="https://i.stack.imgur.com/f1pnU.png" rel="nofollow noreferrer">connect info</a></p>
  
  <p>and code is like this:</p>
  
  <pre><code>`from sshtunnel import SSHTunnelForwarder
  import MySQLdb
  with SSHTunnelForwarder(
          ('2.2.2.2', 22),
          ssh_username='name2',
          ssh_password='mypassword',
          remote_bind_address=('127.0.0.1', 3306)
  ) as tunnel:
      connection = MySQLdb.connect(
      user='name1',
      password='mypassword',
      host='1.1.1.1',
      database='mydata',
      port=3306)
  </code></pre>
  
  <p>I searched some example code like:</p>
  
  <pre><code>from sshtunnel import SSHTunnelForwarder
  import MySQLdb
  
  with SSHTunnelForwarder(
          (_host, _ssh_port),
          ssh_username=_username,
          ssh_password=_password,
          remote_bind_address=(_remote_bind_address, _remote_mysql_port),
          local_bind_address=(_local_bind_address, _local_mysql_port)
  ) as tunnel:
      connection = MySQLdb.connect(
      user=_db_user,
      password=_db_password,
      host=_local_bind_address,
      database=_db_name,
      port=_local_mysql_port)
  </code></pre>
  
  <p>I want to know that did I do the right way to built ssh or connect to mysql? Thanks for help! </p>
  
  <p><strong>update:</strong>
  the error message:</p>
  
  <pre><code>2017-06-15 17:52:58,415| ERROR   | Could not connect to gateway 1.1.1.1:22 : 110
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 6, in &lt;module&gt;
    File "build/bdist.linux-x86_64/egg/sshtunnel.py", line 1483, in __enter__
    File "build/bdist.linux-x86_64/egg/sshtunnel.py", line 1225, in start
    File "build/bdist.linux-x86_64/egg/sshtunnel.py", line 1037, in _raise
  sshtunnel.BaseSSHTunnelForwarderError: Could not establish session to SSH gateway
  </code></pre>