从GAE与在Compute Engine实例上运行的mysql服务器连接

维沙尔·索里亚(Vishal Soriya)

如何通过Google App Engine与在Compute Engine实例上运行的mysql服务器通信?我们正在使用Google App Engine作为前端。我们希望将数据库托管在Compute Engine上运行的mysql服务器上。有什么办法可以做到这一点?

我们经历了以下过程:https : //cloud.google.com/solutions/mysql-remote-access

程式码片段:

if (os.getenv('SERVER_SOFTWARE') and
  os.getenv('SERVER_SOFTWARE').startswith('Google App Engine/')):
  db=MySQLdb.connect(host="InternalIP", port=3306, db='test_database', user='root',passwd="db_password")
else:
  db = MySQLdb.connect(host='127.0.0.1', port=3306, db='test_database', user='root', charset='utf8')

cursor = db.cursor()
logging.info("Hey there looks like I am connected")
E·安德森

Igor在上面评论暗示了如何使它工作。我设法制作了一个可运行的应用程序,并对记录的解决方案进行了以下更改

  1. host参数指定一个公共(外部)IP地址,而不是unix_socket
  2. 用替换MySQLdb pymysql特别是,您要将pymysql目录从该GitHub存储库复制到您的应用程序目录中。使用pymysql还意味着您无需添加MySQLdblibraries:app.yaml部分。
  3. connections.py第52行附近的,更改以下行:

    if _py_version == (2, 7) and not IRONPYTHON
    

    if _py_version == (2, 7) and not IRONPYTHON and not os.getenv('SERVER_SOFTWARE', '').startswith('Google App Engine'):
    
  4. 您可能需要更改mysql中的MySQL权限授予,以允许从App Engine源IP地址进行访问

需要此解决方法的原因是App Engine套接字库未实现中的_socketio包装器使用的某些异步IO原语pymysql同时MySQLdb,App Engine随附模块包装了一个C库,该C库不知道如何使用App Enginesockets库(并且可能未编译套接字支持)。

我将看看后一种组合是否可以解决,但与此同时,以上3个步骤应提供一种解决方法,可用于连接到您自己的MySQL或Cloud SQL版本2

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

如何测试在 Compute Engine 实例上运行的 HTTP 服务器而不将其公开?

来自分类Dev

无法从第二个VM实例连接到Google Compute Engine上的MongoDB服务器

来自分类Dev

连接到Cloud SQL的Google Compute Engine托管的Rails应用中的MySQL服务器已消失

来自分类Dev

将Google colab连接到Google Compute Engine实例上的运行时

来自分类Dev

如何使用GUI连接到Google Compute Engine虚拟服务器?

来自分类Dev

运行GAE开发服务器时,本地MySQLdb连接失败,并出现paramstyle的AttributeError错误

来自分类Dev

在Google Cloud(Debian)Compute Engine上启动X服务器

来自分类Dev

授权 GAE 服务器访问 Cloud SQL 实例

来自分类Dev

MongoInternalException:在GAE本地服务器上运行时,DBPort.findOne失败

来自分类Dev

如何休眠Google Compute Engine服务器?

来自分类Dev

Google Compute Engine服务器的地理位置?

来自分类Dev

Google Compute Engine服务器的地理位置?

来自分类Dev

Google Compute Engine作为Minecraft服务器

来自分类Dev

更改 chown 主文件夹后无法连接到 SSH 服务器 Google Compute Engine

来自分类Dev

GAE(谷歌应用引擎)上的应用程序可以访问VPS /专用服务器上的Mysql服务器主机吗?

来自分类Dev

适用于Web服务器或App Engine的Google Compute Engine

来自分类Dev

适用于Web服务器或App Engine的Google Compute Engine

来自分类Dev

GAE开发服务器导致MySQL连接错误-类似的连接代码在交互式Shell中有效

来自分类Dev

MySQL Workbench和Google Compute Engine连接

来自分类Dev

HTTPS无法在Google Compute Engine上运行

来自分类Dev

PHP:在Google Cloud Compute中创建服务器实例时出错

来自分类Dev

Google Compute Engine服务器的自定义域

来自分类Dev

从Google Compute Engine外部访问Node.js服务器

来自分类Dev

在哪里可以找到Google Compute Engine的名称服务器?

来自分类Dev

如何通过SSL / TSL与Google Compute Engine上托管的gRPC服务器通信?

来自分类Dev

如何在 Google Compute Engine 上访问 Jolokia 服务器

来自分类Dev

在GAE上运行Websocket

来自分类Dev

无法连接到在 aws ec2 实例的节点服务器上运行的网站。

来自分类Dev

无法通过SSH连接到Compute Engine实例

Related 相关文章

  1. 1

    如何测试在 Compute Engine 实例上运行的 HTTP 服务器而不将其公开?

  2. 2

    无法从第二个VM实例连接到Google Compute Engine上的MongoDB服务器

  3. 3

    连接到Cloud SQL的Google Compute Engine托管的Rails应用中的MySQL服务器已消失

  4. 4

    将Google colab连接到Google Compute Engine实例上的运行时

  5. 5

    如何使用GUI连接到Google Compute Engine虚拟服务器?

  6. 6

    运行GAE开发服务器时,本地MySQLdb连接失败,并出现paramstyle的AttributeError错误

  7. 7

    在Google Cloud(Debian)Compute Engine上启动X服务器

  8. 8

    授权 GAE 服务器访问 Cloud SQL 实例

  9. 9

    MongoInternalException:在GAE本地服务器上运行时,DBPort.findOne失败

  10. 10

    如何休眠Google Compute Engine服务器?

  11. 11

    Google Compute Engine服务器的地理位置?

  12. 12

    Google Compute Engine服务器的地理位置?

  13. 13

    Google Compute Engine作为Minecraft服务器

  14. 14

    更改 chown 主文件夹后无法连接到 SSH 服务器 Google Compute Engine

  15. 15

    GAE(谷歌应用引擎)上的应用程序可以访问VPS /专用服务器上的Mysql服务器主机吗?

  16. 16

    适用于Web服务器或App Engine的Google Compute Engine

  17. 17

    适用于Web服务器或App Engine的Google Compute Engine

  18. 18

    GAE开发服务器导致MySQL连接错误-类似的连接代码在交互式Shell中有效

  19. 19

    MySQL Workbench和Google Compute Engine连接

  20. 20

    HTTPS无法在Google Compute Engine上运行

  21. 21

    PHP:在Google Cloud Compute中创建服务器实例时出错

  22. 22

    Google Compute Engine服务器的自定义域

  23. 23

    从Google Compute Engine外部访问Node.js服务器

  24. 24

    在哪里可以找到Google Compute Engine的名称服务器?

  25. 25

    如何通过SSL / TSL与Google Compute Engine上托管的gRPC服务器通信?

  26. 26

    如何在 Google Compute Engine 上访问 Jolokia 服务器

  27. 27

    在GAE上运行Websocket

  28. 28

    无法连接到在 aws ec2 实例的节点服务器上运行的网站。

  29. 29

    无法通过SSH连接到Compute Engine实例

热门标签

归档