我在使用Nodejs和Sequelize连接到vagrant盒子中的MySql时遇到了一个问题。
我可以从Navicat或Python,Nodejs和MySql包连接到Mysql DB。但我无法连接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);
});

发布于 2019-03-07 18:02:23
通常,MySQL在端口3306上工作(您在端口3307上执行请求)。另外,您可以尝试使用MySQL包:https://github.com/mysqljs/mysql。
诚挚的问候。
https://stackoverflow.com/questions/55040030
复制相似问题