最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

NodeJS中的MySQL错误:无法以root身份连接

运维笔记admin17浏览0评论

NodeJS中的MySQL错误:无法以root身份连接

NodeJS中的MySQL错误:无法以root身份连接

我正在开发一个使用NodeJS(Windows为8.9.0)和MySQL(Windows为5.7.0)的小项目。操作系统是WIndows 10 64位。

由于我缺乏Node的经验,我的问题相当简单(缺乏细节): 在我的mysql安装或NodeJS应用程序的mysql模块中,甚至在MySQL工作台的设置中,是这个异常的原因吗? 我想设置(使用密码:YES),可以在错误日志中看到NO,Node应用程序可以连接而不需要密码。 wh,但我不知道在哪里禁用它

这里的控制台日志有例外:

    C:\Users\myPCAccount\git\sampleProject>node app.js
Environment: development
Configuring server
Configuring sequelize
Synchronising database
Configuring passport
Configuring express-server
Server listening on port 3000
Unhandled rejection SequelizeAccessDeniedError: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost' (using password: YES)
    at Handshake._callback (C:\Users\myPCAccount\git\sampleProject\node_modules\sequelize\lib\dialects\mysql\connection-manager.js:83:20)
    at Handshake.Sequence.end (C:\Users\myPCAccount\git\sampleProject\node_modules\mysql\lib\protocol\sequences\Sequence.js:88:24)
    at Handshake.ErrorPacket (C:\Users\myPCAccount\git\sampleProject\node_modules\mysql\lib\protocol\sequences\Handshake.js:132:8)
    at Protocol._parsePacket (C:\Users\myPCAccount\git\sampleProject\node_modules\mysql\lib\protocol\Protocol.js:279:23)
    at Parser.write (C:\Users\myPCAccount\git\sampleProject\node_modules\mysql\lib\protocol\Parser.js:76:12)
    at Protocol.write (C:\Users\myPCAccount\git\sampleProject\node_modules\mysql\lib\protocol\Protocol.js:39:16)
    at Socket.<anonymous> (C:\Users\myPCAccount\git\sampleProject\node_modules\mysql\lib\Connection.js:103:28)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at TCP.onread (net.js:594:20)
From previous event:
    at ConnectionManager.connect (C:\Users\myPCAccount\git\sampleProject\node_modules\sequelize\lib\dialects\mysql\connection-manager.js:55:10)
    at ConnectionManager.<anonymous> (C:\Users\myPCAccount\git\sampleProject\node_modules\sequelize\lib\dialects\abstract\connection-manager.js:247:43)
From previous event:
    at Promise.then (C:\Users\myPCAccount\git\sampleProject\node_modules\sequelize\lib\promise.js:21:17)
    at Model.sync (C:\Users\myPCAccount\git\sampleProject\node_modules\sequelize\lib\model.js:993:6)
    at C:\Users\myPCAccount\git\sampleProject\node_modules\sequelize\lib\sequelize.js:1014:20
From previous event:
    at Function.each (C:\Users\myPCAccount\git\sampleProject\node_modules\sequelize\lib\promise.js:21:17)
    at C:\Users\myPCAccount\git\sampleProject\node_modules\sequelize\lib\sequelize.js:1013:20
    at runCallback (timers.js:789:20)
    at tryOnImmediate (timers.js:751:5)
    at processImmediate [as _immediateCallback] (timers.js:722:5)
From previous event:
    at Promise.then (C:\Users\myPCAccount\git\sampleProject\node_modules\sequelize\lib\promise.js:21:17)
    at Sequelize.sync (C:\Users\myPCAccount\git\sampleProject\node_modules\sequelize\lib\sequelize.js:1000:6)
    at module.exports (C:\Users\myPCAccount\git\sampleProject\config\sequelize.js:32:35)
    at Object.<anonymous> (C:\Users\myPCAccount\git\sampleProject\app.js:32:30)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Function.Module.runMain (module.js:676:10)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:608:3
回答如下:

“使用密码:是”仅表示您的节点应用确实提供了密码。

“使用密码:否”表示您的节点应用程序未提供密码(或指定''作为空密码)。这是否有效取决于您是否在MySQL服务器中创建了没有密码的用户。

出于安全原因,不建议使用空密码创建MySQL用户 - 更不用说root用户。除非您使用TLS证书而不是密码。

发布评论

评论列表(0)

  1. 暂无评论