报错:Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client
发现在终端是可以连上mysql的,但用vscode却不行
数据库版本: 8.0.22
Server version: 8.0.22 MySQL Community Server - GPL
原因:登录数据库的客户端跟mysql8.0不兼容了,mysql8.0密码认证采用了新的密码格式
解决办法:mysql终端输入下面命令
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
root、password 分别为数据库账户,密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
Query OK, 0 rows affected (0.00 sec)
mysql>
在vs code重新连接便可以连上了