Skip to content Skip to sidebar Skip to footer

Why Can I Connect To Mysql Through Shell, But Can't Do It Through Python?

I'm connecting to MySQL db through SSH on server. I managed to do it through MySql workbench and through system shell, which means passwords, username and ip are correct and allowe

Solution 1:

I managed to connect with:

tunnel = sshtunnel.SSHTunnelForwarder((ssh_host, 22), ssh_password=ssh_password, ssh_username=ssh_username,
     remote_bind_address=('localhost', 3306))
tunnel.start()

Apparently the difference was to keep the tunnel open instead of using 'with' statement, though I don't understand what actually happened and I'd appreciate explanation.

Post a Comment for "Why Can I Connect To Mysql Through Shell, But Can't Do It Through Python?"