使用Sequelize的Mysql连接超时

使用Sequelize的Mysql连接超时,mysql,node.js,sequelize.js,Mysql,Node.js,Sequelize.js,我在使用Nodejs和Sequelize连接到vagrant框中的MySql时遇到问题 我可以从Navicat或Python、Nodejs和MySql包连接到MySql数据库。但我无法与Nodejs和Sequelize建立联系。 伙计们,你们知道吗 const Sequelize = require('sequelize'); const sequelize = new Sequelize('blog', 'root', null, { host: 'localhost', di

我在使用Nodejs和Sequelize连接到vagrant框中的MySql时遇到问题

我可以从Navicat或Python、Nodejs和MySql包连接到MySql数据库。但我无法与Nodejs和Sequelize建立联系。 伙计们,你们知道吗

const Sequelize = require('sequelize');
const sequelize = new Sequelize('blog', 'root', null, {
    host: 'localhost',
    dialect: 'mysql',
    operatorsAliases: false,
    port: 3307,
    pool: {
        max: 5,
        min: 0,
        acquire: 40000,
        idle: 20000
    },
});

sequelize
    .authenticate()
    .then(() => {
        console.log('Connection has been established successfully.');
    })
    .catch(err => {
        console.error('Unable to connect to the database:', err);
    });

通常MySQL在端口3306上工作(您在端口3307上执行请求)。 另一方面,您可以尝试使用MySQL包:


致意。

3307是主机中的端口,该端口用于映射vagrant框中的Mysql端口。我可以使用Mysql,但我想在Sequelize软件包中使用ORM功能。我认为您不应该传递空密码。相反,您应该尝试在sequelizejs文档中的“@bereketgebredingle
Null
表示为空白密码。我尝试了
,但仍然连接超时,因此,这是一个端口问题。确保您允许vargant框上的端口。