mysql - SequelizeConnectionRefusedError : connect ECONNREFUSED 127. 0.0.1:3306

标签 mysql node.js express sequelize.js

我使用 Sequelize 作为我的 Node js 应用程序和 Mysql 数据库的 ORM, 在遵循一些教程之后,我添加了此代码以将 mysql 连接到 Node ,但是在录制 npm start 后,我​​收到此错误: 无法连接到数据库:{ SequelizeConnectionRefusedError: connect ECONNREFUSED 127.0.0.1:3306

 const Sequelize = require('sequelize');

 // Option 1: Passing parameters separately
 const sequelize = new Sequelize('Education', 'root','', {
 host: '127.0.0.1',
 dialect: 'mysql'
 } );

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

最佳答案

问题已解决,我在 phpMyadmin 中使用端口:3307 而不是 3306

关于mysql - SequelizeConnectionRefusedError : connect ECONNREFUSED 127. 0.0.1:3306,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57522774/

相关文章:

mysql - 如何在 module.export 函数中使用回调进行 mysql 查询 - nodejs,express

mysql - mysql中一组行的累计和

php - 格式化并输出数据库表中的所有数据

node.js - NodeJs 是事件驱动的吗?

javascript - Node-sqlite3模块安装错误

node.js - 尝试以多对多关系创建一个实例和多个相关实例

mysql - Windows Server 2008 R2 上的 MySQL 5.5 错误 1067

mysql - 如何统计多个表的行数

javascript - NodeJS : HTTP response fired twice

node.js - 如何在 NodeJs 中使用 Android 推送通知发送 Json 对象