Code:
import mysql.connector
import sshtunnel
sshtunnel.SSH_TIMEOUT = 5.0
sshtunnel.TUNNEL_TIMEOUT = 5.0
try:
with sshtunnel.SSHTunnelForwarder(
('ssh.pythonanywhere.com'),
ssh_username='businessaccount', ssh_password='xxxxxxxx',
remote_bind_address=('BusinessAccount.mysql.pythonanywhere-services.com', 3306)
) as tunnel:
print("tunnel #1: "+str(tunnel.local_bind_port))
mydb = mysql.connector.connect(
user='BusinessAc',
password='xxxxxxxx',
host='127.0.0.1',
port=tunnel.local_bind_port,
database='BusinessAc$default',
)
mydb.close()
except Exception as e:
print(str(e))
Error:
tunnel #1: 50493
2020-09-12 13:56:31,295| ERROR | Could not establish connection from ('127.0.0.1', 50493) to remote side of the tunnel
2020-09-12 13:56:31,325| ERROR | Secsh channel 0 open FAILED: open failed: Administratively prohibited
2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0
I just follow what's in the documentation but I got this kind of error.
I'm using python 3.5.1