title: Connecting to mysql db via ssh with python
body: <p>I have tried solutions found on other SO questions but none of them have worked for me. I am attempting to pull data from a mysql db running on a remote server by setting up an ssh tunnel. My code is as follows:</p>
  
  <pre><code>server = sshtunnel.SSHTunnelForwarder(
              ('10.6.41.10', 22),
              ssh_username= 'serveruser',
              ssh_password= 'serverpw',
              remote_bind_address=('127.0.0.1', 3306))
  
  server.start()
  print(server.local_bind_port)
  
  cnx = mysql.connector.connect(user='root', password='mysqlpw',
                                host='127.0.0.1',
                                database='mydb',
                                charset='utf8',
                                use_unicode='FALSE',
                                port = 3306)
  </code></pre>
  
  <p>However, when I run this code I receive: </p>
  
  <pre><code>1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
  </code></pre>
  
  <p>I have also tried adding</p>
  
  <pre><code>local_bind_address = ('0.0.0.0', 3306)
  </code></pre>
  
  <p>to the sshtunnel setup and instead recieved</p>
  
  <pre><code>Problem setting SSH Forwarder up: Couldn't open tunnel 0.0.0.0:3306 &lt;&gt; 127.0.0.1:3306 might be in use or destination not reachable
  </code></pre>
  
  <p>I don't fully understand the remote_bind_address and local_bind_address, so my guess is that  must be doing something wrong there. I know my username/pw/server info is correct, I am able to ssh into my server via terminal and then use </p>
  
  <pre><code>mysql -h 127.0.0.1 -u root -p
  </code></pre>
  
  <p>to successfully log into my mysql server. So what do I need to fix to get it running in python? Thanks.</p>