[英]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.