无法从google云计算vm示例连接到独立的mysql服务器

j7dteeu8  于 2021-06-18  发布在  Mysql
关注(0)|答案(1)|浏览(339)

我办公室有一台运行mysql的服务器。我已经连接到这个服务器从笔记本电脑和个人电脑远远。但是,当尝试从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

这个虚拟机是上个月从股票图片安装的ubuntu16.04.5。我尝试使用mysql connector python从python3.7控制台进行连接。
有什么防火墙规则我需要补充吗?

2fjabf4q

2fjabf4q1#

我的错,我们的电脑关闭了防火墙的3306端口。我试着从我们的网络外部访问服务器,发现它已经无法访问了。谢谢你怀疑我约翰

相关问题