[英]Connecting Cloud Run Node app to Cloud SQL using Sequelize
I am trying to deploy a Nodejs app on Google Cloud Run
which is supposed to connect to the Cloud SQL
MySQL database using Sequelize
ORM.我正在尝试在
Google Cloud Run
上部署一个 Nodejs 应用程序,该应用程序应该使用Sequelize
ORM 连接到Cloud SQL
MySQL 数据库。
It works fine if I use the local proxy for the cloud sql instance, but when I try to deploy it to Cloud Run, Sequelize is not able to find the db instance.如果我为云 sql 实例使用本地代理,它工作正常,但是当我尝试将它部署到 Cloud Run 时,Sequelize 无法找到数据库实例。
I tried giving '/cloudsql/' in the host property of sequelize, tried the public IP (it times out every time)我尝试在sequelize的主机属性中给出'/cloudsql/',尝试了公共IP(每次都超时)
This is what my config looks like:这是我的配置的样子:
exports.PRODUCTION = {
HOST: "/cloudsql/<connection-name-here>",
USER: "<db-user",
PASSWORD: "<db-password>",
DB: "<db-name>",
dialect: "mysql",
pool: {
max: 5,
min: 0,
acquire: 30000,
idle: 10000
}
};
What am I missing here?我在这里想念什么?
Thanks in advance.提前致谢。
I figured out my mistake.我发现了我的错误。 I was passing the UNIX socket path in the host property (facepalm)
我在主机属性(facepalm)中传递了 UNIX 套接字路径
You have to pass the socket path in the socketPath property in dialectOptions in the config.您必须在配置中 dialectOptions 的 socketPath 属性中传递套接字路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.