node连接Mysql8.0报错:Error: ER_NOT_SUPPORTED_AUTH_MODE

报错信息:

  code: 'ER_NOT_SUPPORTED_AUTH_MODE',
  errno: 1251,
  sqlMessage: 'Client does not support authentication protocol requested by server; consider upgrading MySQL client',
  sqlState: '08004',
  fatal: true

原因:mysql8.0以上加密方式,Node还不支持。

解决方案:

  1. 在命令提示行中键入:mysql -u root -p
  2. 输入 alter user 'root'@'localhost' identified with mysql_native_password by '12345678';
Query OK, 0 rows affected (0.04 sec)
  1. 输入flush privileges;
Query OK, 0 rows affected (0.02 sec)

问题解决。

你可能感兴趣的:(node连接Mysql8.0报错:Error: ER_NOT_SUPPORTED_AUTH_MODE)