Client does not support authentication protocol requested by server

本文涉及的产品
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS PostgreSQL,集群系列 2核4GB
简介: Client does not support authentication protocol requested by server

宿命论是那些缺乏意志力的弱者的借口。——罗曼·罗兰

今天试了试使用js连接数据库,发现报错Client does not support authentication protocol requested by server; consider upgrading MySQL client

乍一看,代码好像没问题

var mysql = require("mysql");
let connection = mysql.createConnection({
    host: "127.0.0.1",
    port: 3306,
    user: "root",
    password: "789456",
    database: "ruben"
});
connection.connect();
connection.query("select * from user", function (error, results, fields) {
    if (error) throw error;
    console.log(results);
    console.log(fields);
});
connection.end();

但我的mysql版本是8.0.22

所以需要执行以下sql

1
2
alteruser'root'@'localhost' identified with mysql_native_password by'789456';
flush privileges;

然后就可以正常执行了

相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
2月前
|
应用服务中间件 网络安全 Apache
403 Forbidden 500 Internal Server Error
403 Forbidden 500 Internal Server Error
|
5月前
|
关系型数据库 MySQL 数据安全/隐私保护
Navicat连接mysql8报错解决:1251- Client does not support authentication protocol requested by server
Navicat连接mysql8报错解决:1251- Client does not support authentication protocol requested by server
961 0
|
7月前
Failed to connect to apiserver: the server has asked for the clieto provide credentials
Failed to connect to apiserver: the server has asked for the clieto provide credentials
55 0
|
7月前
|
关系型数据库 MySQL 数据库
navicat本地连接mysql出现1251--Client does not support authentication protocol requested by server的解决方法
navicat本地连接mysql出现1251--Client does not support authentication protocol requested by server的解决方法
556 0
|
7月前
|
关系型数据库 MySQL 数据库
Client does not support authentication protocol requested by server; consider upgrading MySQL client
Client does not support authentication protocol requested by server; consider upgrading MySQL client
|
7月前
|
Kubernetes 容器
k8s-unable to connect to the server:x509:certificates signed by unknown authority......
k8s-unable to connect to the server:x509:certificates signed by unknown authority......
355 0
|
关系型数据库 MySQL 数据库
MySql错误 1251 - Client does not support authentication protocol requested by server
MySql错误 1251 - Client does not support authentication protocol requested by server
97 0
|
关系型数据库 MySQL 数据安全/隐私保护
Client does not support authentication protocol requested by server 解决Navicat连接不上MySql服务器报错
Client does not support authentication protocol requested by server 解决Navicat连接不上MySql服务器报错
621 0
Client does not support authentication protocol requested by server 解决Navicat连接不上MySql服务器报错
|
关系型数据库 MySQL
【已解决】Client does not support authentication protocol requested by server; consider upgrading MySQL client
Client does not support authentication protocol requested by server; consider upgrading MySQL client
517 0