MySQL Forums
Forum List  »  Connector/Python

MySQL-connector through SSH-tunnel
Posted by: Yoann LE NY
Date: January 14, 2016 10:14AM

Hi everybody,

I am using windows 7 with Python 3.4 (with Pycharm) and try to acces a remote mySQL-database through SSH with a private key, just like it is working with MySQL-Workbench in the following picture :

I use SSHTunnel ( to setup the SSH-Tunnel as follow :

from sshtunnel import SSHTunnelForwarder

server = SSHTunnelForwarder(
("", 3307),
remote_bind_address=('', 3306))

Which works smoothly.

Then I try to connect through the MySQL-connector for Python as follow :

cnx=mysql.connector.connect(user='yoann_builder', password='pass',host="", port=3307)

And I got the following error :

mysql.connector.errors.InterfaceError: 2003: Can't connect to MySQL server on '' (10061 No connection could be made because the target machine actively refused it)

The problem is, to my understanding, "How to specify to the connector to use the SSH-Tunnel?"

Thanks in advance for your help.

Best Regards

Options: ReplyQuote

Written By
MySQL-connector through SSH-tunnel
January 14, 2016 10:14AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.