SequelizeConnectionRefusedError:连接ECONNREFUSED 127.0.0.1:3306 [英] SequelizeConnectionRefusedError: connect ECONNREFUSED 127.0.0.1:3306

查看:1084
本文介绍了SequelizeConnectionRefusedError:连接ECONNREFUSED 127.0.0.1:3306的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Sequelize用作节点js应用程序和Mysql数据库的ORM, 在遵循了一些教程之后,我添加了这段代码以将mysql连接到节点,但是在点击npm后,我得到了这个错误: 无法连接到数据库:{SequelizeConnectionRefusedError:连接ECONNREFUSED 127.0.0.1:3306

I'm using Sequelize as an ORM to my node js app and Mysql database , after following some tutorials i m adding this code to connect mysql to the node but after taping npm start i m getting this error : Unable to connect to the database: { 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

Problem solved i was using port : 3307 in phpMyadmin instead of 3306

这篇关于SequelizeConnectionRefusedError:连接ECONNREFUSED 127.0.0.1:3306的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆