支持mysql8的客户端_MySQL 8.0-客户端不支持服务器请求的身份验证协议;考虑升级MySQL客户端...

bd96500e110b49cbb3cd949968f18be7.png

I can't make a simple connection to the server for some reason. I install the newest MySQL Community 8.0 database along with Node.JS with default settings.

This is my node.js code

var mysql = require('mysql');

var con = mysql.createConnection({

host: "localhost",

user: "root",

password: "password",

insecureAuth : true

});

con.connect(function(err) {

if (err) throw err;

console.log("Connected!");

});

Below is the error found in Command Prompt:

C:\Users\mysql-test>node app.js

C:\Users\mysql-test\node_modules\mysql\lib\protocol\Parse

r.js:80

throw err; // Rethrow non-MySQL errors

^

Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client

at Handshake.Sequence._packetToError (C:\Users\mysql-

test\node_modules\mysql\lib\protocol\sequences\Sequence.js:52:14)

at Handshake.ErrorPacket (C:\Users\mysql-test\node_mo

dules\mysql\lib\protocol\sequences\Handshake.js:130:18)

at Protocol._parsePacket (C:\Users\mysql-test\node_mo

dules\mysql\lib\protocol\Protocol.js:279:23)

at Parser.write (C:\Users\mysql-test\node_modules\mys

ql\lib\protocol\Parser.js:76:12)

at Protocol.write (C:\Users\mysql-test\node_modules\m

ysql\lib\protocol\Protocol.js:39:16)

at Socket. (C:\Users\mysql-test\node_modul

es\mysql\lib\Connection.js:103:28)

at Socket.emit (events.js:159:13)

at addChunk (_stream_readable.js:265:12)

at readableAddChunk (_stream_readable.js:252:11)

at Socket.Readable.push (_stream_readable.js:209:10)

--------------------

at Protocol._enqueue (C:\Users\mysql-test\node_module

s\mysql\lib\protocol\Protocol.js:145:48)

at Protocol.handshake (C:\Users\mysql-test\node_modul

es\mysql\lib\protocol\Protocol.js:52:23)

at Connection.connect (C:\Users\mysql-test\node_modul

es\mysql\lib\Connection.js:130:18)

at Object. (C:\Users\mysql-test\server.js:

11:5)

at Module._compile (module.js:660:30)

at Object.Module._extensions..js (module.js:671:10)

at Module.load (module.js:573:32)

at tryModuleLoad (module.js:513:12)

at Function.Module._load (module.js:505:3)

at Function.Module.runMain (module.js:701:10)

But I am still not sure how to fix my problem. Any help would be appreciated :D

解决方案

Execute the following query in MYSQL Workbench

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'

Where root as your user

localhost as your URL

and password as your password

Then run this query to refresh privileges:

flush privileges;

Try connecting using node after you do so.

If that doesn't work, try it without @'localhost' part.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值