简体   繁体   English

无法从 App Engine Node JS 标准环境连接 Google Cloud MySQL 实例

[英]Not able to connect Google Cloud MySQL Instance from App Engine Node JS standard environment

Not able to connect MySQL Google Cloud Instance Database from NodeJS/Express App Engine.无法从 NodeJS/Express App Engine 连接 MySQL Google Cloud Instance Database。

Able to connect Database locally as I have added my local machine IP in "Authorized networks" of SQL Instance Settings.能够在本地连接数据库,因为我在 SQL 实例设置的“授权网络”中添加了我的本地计算机 IP。

Tried using below code in NodeJS App Engine Instance but facing error not able to connect db.尝试在 NodeJS App Engine 实例中使用以下代码,但遇到无法连接数据库的错误。

{
    "username": "abcd",
    "password": "abcd123",
    "database": "dummy",
    "host": "localhost",
    "socketPath": "/cloudsql/{project-name}:{instance-zone}:{instance-name}",
    "post": 3306,
    "dialect": "mysql",
    "dialectOptions": {
          "socketPath": "/cloudsql/{project-name}:{instance-zone}:{instance-name}"
    }
  }

How can I solve this issue?我该如何解决这个问题?

Having the Cloud SQL MySQL Instance on a different project as the GAE app caused trhe issue.将 Cloud SQL MySQL 实例放在另一个项目上,因为 GAE 应用程序导致了问题。

Just moving the isntance solved the issue只需移动实例即可解决问题

I think you need vpc_access_connector in app.yaml.我认为您需要在 app.yaml 中使用 vpc_access_connector。

or you can follow sample code from gcp app engine nodejs https://github.com/GoogleCloudPlatform/nodejs-docs-samples/tree/master/appengine/cloudsql或者您可以按照 gcp app engine nodejs https://github.com/GoogleCloudPlatform/nodejs-docs-samples/tree/master/appengine/cloudsql的示例代码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法从 App Engine 中的 Node JS 连接到 Cloud MySQL - Unable to connect to Cloud MySQL from Node JS in App Engine 允许App Engine标准环境连接到Compute Engine Mysql - Allow App Engine Standard Environment to connect to Compute Engine Mysql Google App Engine连接外部MySQL Node.js - Google App Engine connect external MySQL Node.js MySQL连接到Google App Engine实例 - MySQL connect to google app engine instance 在灵活的环境中将Google App Engine与Google Cloud Storage相连接 - Connect Google App Engine with Google Cloud Storage in flexible environment 无法使用Google App Engine上的Slim框架连接到Google Cloud SQL - Not able to connect to Google Cloud SQL with Slim framework on Google App Engine 从 Cloud Run PHP 连接到 Google Cloud Compute Engine 虚拟机上的 MySQL 实例 - Connect to MySQL instance on Google Cloud Compute Engine VM from Cloud Run PHP 我无法使用内部 IP 从另一个实例连接到在 Google Compute 引擎上运行的 mysql 服务器 - I am not able to connect to mysql server running on Google Compute engine from another instance using internal IP Google App Engine-使用mysqli用php连接到SQL Cloud实例 - Google App Engine - Connect to SQL Cloud Instance with php using mysqli 无法从App Engine应用程序(灵活的环境)PHP连接到MySQL第二代实例 - Unable to connect to a MySQL Second Generation instance from an App Engine application (flexible environment) PHP
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM