简体   繁体   English

将 Firebase 函数与 Google Cloud SQL MYSQL 连接时出现 ECONNREFUSED

[英]ECONNREFUSED when connecting Firebase Function with Google Cloud SQL MYSQL

Here's my config.json from Sequelize:这是我来自 Sequelize 的 config.json:

{
  "development": {
    "username": "root",
    "password": "xxxx",
    "database": "xxxx",
    "host": "127.0.0.1",
    "dialect": "mysql",
    "dialectOptions": {
      "socketPath": "/cloudsql/xxx:xxxx:xxxx"
    }
  },
  ...
}

And I deployed at Firebase Functions with firebase deploy .我使用 firebase deploy 在 Firebase Functions firebase deploy

But when I do something with database, it shows SequelizeConnectionRefusedError: connect ECONNREFUSED /cloudsql/xxx:xxx:xxx但是当我对数据库做一些事情时,它显示SequelizeConnectionRefusedError: connect ECONNREFUSED /cloudsql/xxx:xxx:xxx

Here's a working config:这是一个工作配置:

const sequelize = new Sequelize("test-db", "test-user", "mypassword", {
  dialect: "mysql",
  host: "/cloudsql/PROJECT:REGION:INSTANCE",
})

Sequalize wants a host that points to the Unix socket. Sequalize 需要一个指向 Unix 套接字的主机。

No other configuration on the Firebase Functions side is necessary. Firebase Functions 端不需要其他配置。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM