我正在尝试使用sshtunnel连接远程mysql数据库,但出现以下错误:
mysql.connector.errors.DatabaseError: 2003 (HY000): Can't connect to MySQL server on 'WWW.XXX.YYY.ZZ' (10061)
我在stackoverflow/其他站点中尝试了旧查询的可能解决方案,但没有任何效果。
脚本:
import mysql.connector as myCon
import sshtunnel
server = sshtunnel.SSHTunnelForwarder(
('WWW.XXX.YYY.ZZ', 22),
ssh_username='dbuser',
ssh_password='dbuser',
remote_bind_address=('WWW.XXX.YYY.ZZ', 3306)
)
server.start()
connection = myCon.connect(host='WWW.XXX.YYY.ZZ', port=server.local_bind_port, user='demo', password='demo', database='ADC_test')
请帮助下面的错误
错误:
Traceback (most recent call last):
File "C:\Python36\lib\site-packages\mysql\connector\connection_cext.py", line 176, in _open_connection
self._cmysql.connect(**cnx_kwargs)
_mysql_connector.MySQLInterfaceError: Can't connect to MySQL server on 'WWW.XXX.YYY.ZZ' (10061)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Sunil_Work\psnl\python\pyCharm\PyMySQL\Connect to MYSQL.py", line 14, in <module>
connection = myCon.connect(host='WWW.XXX.YYY.ZZ', port=server.local_bind_port, user='demo', password='demo', database='ADC_test')
File "C:\Python36\lib\site-packages\mysql\connector\__init__.py", line 182, in connect
return CMySQLConnection(*args,**kwargs)
File "C:\Python36\lib\site-packages\mysql\connector\connection_cext.py", line 78, in __init__
self.connect(**kwargs)
File "C:\Python36\lib\site-packages\mysql\connector\abstracts.py", line 736, in connect
self._open_connection()
File "C:\Python36\lib\site-packages\mysql\connector\connection_cext.py", line 179, in _open_connection
sqlstate=exc.sqlstate)
mysql.connector.errors.DatabaseError: 2003 (HY000): Can't connect to MySQL server on 'WWW.XXX.YYY.ZZ' (10061)
暂无答案!
目前还没有任何答案,快来回答吧!