Google cloud platform 获得;未处理的拒绝SequelizeConnectionError:connect eNot“;连接到SQL云时

Google cloud platform 获得;未处理的拒绝SequelizeConnectionError:connect eNot“;连接到SQL云时,google-cloud-platform,google-cloud-sql,Google Cloud Platform,Google Cloud Sql,我正在Google App Engine中设置NodeJS后端,当我尝试连接到SQL云(使用sequelize+postgres)时,我遇到以下错误: Unhandled rejection SequelizeConnectionError: connect ENOENT /cloudsql/tar:us-central1:dbpointofsales/.s.PGSQL.5432 at connection.connect.err (/home/mf/backend/node_modul

我正在Google App Engine中设置NodeJS后端,当我尝试连接到SQL云(使用sequelize+postgres)时,我遇到以下错误:

Unhandled rejection SequelizeConnectionError: connect ENOENT /cloudsql/tar:us-central1:dbpointofsales/.s.PGSQL.5432
    at connection.connect.err (/home/mf/backend/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:182:24)
    at Connection.connectingErrorHandler (/home/mf/backend/node_modules/pg/lib/client.js:163:14)
    at Connection.emit (events.js:182:13)
    at Socket.reportStreamError (/home/mf/backend/node_modules/pg/lib/connection.js:71:10)
    at Socket.emit (events.js:182:13)
    at emitErrorNT (internal/streams/destroy.js:82:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
    at process._tickCallback (internal/process/next_tick.js:63:19)

Connect ENOUNT表示系统无法连接到mysql,因为其路径不正确。 使用指定的代码更新models/index.js文件。要找到mysql套接字的路径,请转到文件here/etc/mysql/my.cnf(此路径可能取决于您的服务器)。例如,/etc/my.cnf。在这里,您将找到套接字的路径

请验证,它需要管理权限(ubuntu上的sudo)。 确认登录凭据正确,端口已打开

您必须验证连接的设置,然后您可以尝试确认连接

测试连接

续集

.authenticate()

.然后(()=>{

})

.catch(错误=>{

}))

具有密钥socketPath的模块mysql

var sequelize=新的sequelize(“数据库”、用户名、密码、{

host: "localhost",

dialect: "mysql",

logging: function () {},

pool: {

    max: 5,

    min: 0,

    idle: 10000

},

dialectOptions: {

    socketPath: "/var/run/mysqld/mysqld.sock"

},

define: {

    paranoid: true

}
}))

console.error('Unable to connect to the database:', err);
host: "localhost",

dialect: "mysql",

logging: function () {},

pool: {

    max: 5,

    min: 0,

    idle: 10000

},

dialectOptions: {

    socketPath: "/var/run/mysqld/mysqld.sock"

},

define: {

    paranoid: true

}