【发布时间】:2021-12-06 07:49:34
【问题描述】:
我正在尝试连接到托管在 pythonanywhere.com 上的 MySQL 数据库
但它带来了以下错误
2021-10-19 13:02:38,943| ERROR | Secsh channel 0 open FAILED: open failed: Administratively prohibited
2021-10-19 13:02:38,943| ERROR | Could not establish connection from local ('127.0.0.1', 62213) to remote ('lewisMachilika.mysql.pythonanywhere-services.com', 3306) side of the tunnel: open new channel ssh error: ChannelException(1, 'Administratively prohibited')
我的文件是
import MySQLdb
import sshtunnel
sshtunnel.SSH_TIMEOUT = 5.0
sshtunnel.TUNNEL_TIMEOUT = 5.0
with sshtunnel.SSHTunnelForwarder(
('ssh.pythonanywhere.com'),
ssh_username='xxxxx', ssh_password='xxxxxx',
remote_bind_address=('xxxxxxxx', 3306)
) as tunnel:
connection = MySQLdb.connect(
user='xxxxxx',
passwd='xxxxx',
host='127.0.0.1', port=tunnel.local_bind_port,
db='xxxxxx',
)
# Do stuff
connection.close()
【问题讨论】:
-
隧道已在您尝试使用的 ssh 服务器上禁用。这是共享内容的正确配置。
-
您需要付费帐户才能在 PythonAnywhere 上使用 SSH(包括 SSH 隧道)。
标签: python mysql pythonanywhere