javascript - Access denied for user 'root'@'localhost' (using password: YES)
学习ing
学习ing 2017-06-12 09:20:35
0
3
972

The mysql connection is successful through the terminal in mac
The connection is successful through the graphical tool Navicat

Failed to connect to mysql through nodejs

Code:

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();
}

Connection error
Access denied for user 'root'@'localhost' (using password: YES)
code: 'ER_ACCESS_DENIED_ERROR',
errno: 1045,
sqlState: '28000'

Please ask God for guidance, thank you!

学习ing
学习ing

reply all(3)
黄舟

The account you are using does not have permission to log in to the database..
Try to authorize both localhost and 127.0.0.1 respectively

仅有的幸福

Make sure your username and password are not entered incorrectly.
Please confirm whether you have access rights. For details, please refer to the next article: https://faceghost.com/article...

学霸

grant all privileges on . to 'root'@'localhost' identified by 'your password' with grant option;

flush privileges;

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template