javascript - Access denied for user 'root'@'localhost' (using password: YES)
学习ing
学习ing 2017-06-12 09:20:35
[MySQL讨论组]

在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'

求大神指导指导,谢谢!

学习ing
学习ing

全部回复(3)
黄舟

所用账号没权限登录数据库吧..
试下在localhost127.0.0.1都分别授权吧

仅有的幸福

确定您的用户名和密码没有输入错误的话。
请确定是否有访问权限,具体可参看下篇文章:https://faceghost.com/article...

欧阳克

grant all privileges on . to 'root'@'localhost' identified by '你的密码' with grant option;

flush privileges;

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号