我的办公室中有一台运行MySQL的服务器。我已经从远方的笔记本电脑和PC连接到该服务器。但是,当尝试从Google Cloud Compute Engine VM实例连接到它时,出现以下错误:
>>> import mysql.connector
>>> dbconfig = {'host': 'redacted', 'user': 'redacted', 'database': 'redacted', 'password': 'redacted'}
>>> cnx = mysql.connector.connect(**dbconfig)
Traceback (most recent call last):
File "/home/me/anaconda3/lib/python3.7/site-
packages/mysql/connector/connection_cext.py", line 176, in _open_connection
self._cmysql.connect(**cnx_kwargs)
_mysql_connector.MySQLInterfaceError: Lost connection to MySQL server at 'reading initial communication packet', system error: 104
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/me/anaconda3/lib/python3.7/site-packages/mysql/connector/__init__.py", line 172, in connect
return CMySQLConnection(*args, **kwargs)
File "/home/me/anaconda3/lib/python3.7/site-packages/mysql/connector/connection_cext.py", line 78, in __init__
self.connect(**kwargs)
File "/home/me/anaconda3/lib/python3.7/site-packages/mysql/connector/abstracts.py", line 731, in connect
self._open_connection()
File "/home/me/anaconda3/lib/python3.7/site-packages/mysql/connector/connection_cext.py", line 179, in _open_connection
sqlstate=exc.sqlstate)
mysql.connector.errors.OperationalError: 2013 (HY000): Lost connection to
MySQL server at 'reading initial communication packet', system error: 104
VM是上个月从股票映像安装的Ubuntu 16.04.5。我尝试使用mysql-connector-python从python 3.7控制台进行连接。
也许我需要添加任何防火墙规则吗?
答案 0 :(得分:2)
糟糕,我们的IT部门关闭了防火墙中的3306端口。我尝试从网络外部访问服务器,但发现该服务器不再可用。 感谢您怀疑我约翰