关于mysql8.0无法连接的问题

关于升级mysql8.0无法连接的问题 最近朋友遇到canal无法连接数据库的问题
报错代码:

ERROR c.a.otter.canal.parse.inbound.mysql.MysqlEventParser - dump address /127.0.0.1:3306 has an error, retrying. caused by com.alibaba.otter.canal.parse.exception.CanalParseException:

这个是nodejs无法连接的错误
代码:
var mysql = require('mysql'); var connection = mysql.createConnection({ host: 'localhost', user: 'root', password: '', database: 'test_db', // insecureAuth : true, }); connection.query('SELECT * FROM users', function(err, rows, fields) { if (err) throw err; });

报错
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)

解决办法
  • 第一种、升级mysql客户端client
  • 第二种
    进入mysql命令行执行
    ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

    flush privileges;

    【关于mysql8.0无法连接的问题】就可以了!
    参考来源stackoverflow
    其他canal连接不上的问题解决方案

    推荐阅读