嗨,我正在尝试通过 sequelize 连接到我的 MySQL 数据库,但无济于事..
我提供的连接数据是 100% 正确的,我可以通过 phpmyadmin 连接到我的 MySQL 数据库。
这是我的代码:
var Sequelize = require('sequelize-mysql').sequelize;
var dbConnector = function()
{
var sequelize = new Sequelize
(
'dbname',
'userName',
'password',
{
host: "ip",
port: port,
dialect: 'mysql'
}
);
var getCoutries = function ()
{
sequelize.query("SELECT * FROM `Country`")
.success
(
function(myTableRows)
{
console.log(myTableRows)
}
)
.error
(
function(error)
{
console.log(error);
// geting an error:
//[Error: connect ECONNREFUSED]
//code: 'ECONNREFUSED',
//errno: 'ECONNREFUSED',
//syscall: 'connect',
//fatal: true }
}
)
;
}
getCoutries();
};