我阅读了与从GCF连接到Cloud SQL中托管的MysQL有关的所有文档仍然无法连接.另外,尝试了与此相关的SQLAlchemy .我正在使用以下连接
I read all documentation related to connecting to MysQL hosted in Cloud SQL from GCF and still can't connect. Also, tried all hints in documentation of SQLAlchemy related to this. I am using the following connection
con = 'mysql+pymysql://USER:PASSWORD@/MY_DB?unix_socket=/cloudsql/Proj_ID:Zone:MySQL_Instance_ID' mysqlEngine = sqlalchemy.create_engine(con)我得到的错误是:
(pymysql.err.OperationalError)(2003,无法连接到'localhost'上的MySQL服务器([Errno 111]连接被拒绝)")(此错误的背景位于: sqlalche.me/e/e3q8 )
推荐答案在获得Google支持的长期支持后,我们发现原因是:我们应该在没有任何防火墙规则的情况下启用对Cloud SQL的公共访问.它没有证件,可能使您发疯,但是支持团队的银弹说:它是beta版!
After a long thread with Google Support, we found the reason to be: simply we should enable public access to Cloud SQL without any firewall rule. It is undocumented and can drive you crazy, but the silver bullet for the support team is to say: it is in beta!
更多推荐
使用Python和SQLAlchemy从Google Cloud Function连接到Cloud SQL
发布评论