在mac中通过终端连接mysql连接成功
通过图形工具Navicat 连接成功
通过nodejs连接mysql失败
代码:
function query(sql, params, callback) {
var op = {
host: '127.0.0.1',
port: '3306',
user: 'root',
password: '111111',
database: 'anjiecc'
};
var client = mysql.createConnection(op);
client.query(sql, function(err, data) {
if (err) {
console.log(err);
} else {
//调用dao回调函数
callback(data);
}
});
client.end();
}
连接报错
Access denied for user 'root'@'localhost' (using password: YES)
code: 'ER_ACCESS_DENIED_ERROR',
errno: 1045,
sqlState: '28000'
求大神指导指导,谢谢!
欧阳克2017-06-12 09:22:35
grant all privileges on . to 'root'@'localhost' identified by '你的密码' with grant option;
flush privileges;