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

我正在使用NodeJS(8.9.0 for Windows)和MySQL(5.7.0 for Windows)的小型项目。操作系统是Windows 10 64位。NodeJS中的MySQL错误:无法以root身份连接

我的问题非常简单(在缺乏细节方面),由于我与节点缺乏经验:
这是例外的在我的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

回答:

“使用密码:YES”只意味着你的节点应用并提供密码。

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

为安全起见,建议不要使用空密码创建MySQL用户 - 更不用说root用户。除非您使用TLS证书而不是密码。

以上是 NodeJS中的MySQL错误:无法以root身份连接 的全部内容, 来源链接: utcz.com/qa/260437.html

回到顶部