1251 - Client does not support authentication protocol requested by server;consider upgrading MySQL

╰半夏微凉° 2022-01-29 15:45 230阅读 0赞

很多人装了MySQL8.0,然后使用Navicat等客户端登录的时候报了以下错误:在这里插入图片描述
原因
MySQL8.0使用新的密码验证插件caching_sha2_password,而MySQL8.0以下的,只要不是太旧的客户端,都是使用mysql_native_password验证插件,两个插件不兼容导致了登录异常

  1. [root@mysql8 ~]# mysql
  2. Welcome to the MySQL monitor. Commands end with ; or \g.
  3. Your MySQL connection id is 12
  4. Server version: 8.0.12 MySQL Community Server - GPL
  5. Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
  6. Oracle is a registered trademark of Oracle Corporation and/or its
  7. affiliates. Other names may be trademarks of their respective
  8. owners.
  9. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  10. mysql> show variables like 'default_authentication_plugin';
  11. +-------------------------------+-----------------------+
  12. | Variable_name | Value |
  13. +-------------------------------+-----------------------+
  14. | default_authentication_plugin | caching_sha2_password |
  15. +-------------------------------+-----------------------+
  16. 1 row in set (0.02 sec)

解决
将default_authentication_plugin设为mysql_native_password,并且以mysql_native_password插件方式更新一下用户密码,例如我登录使用的用户是root@’%’:
1.首先在my.cnf加入以下参数,并重启MySQL实例
default_authentication_plugin=mysql_native_password
2.更新登录用户密码
alter user root@’%’ identified with mysql_native_password by ‘sam123’;

通过以上两个步骤,就可以使用Navicat登录了,如果还有问题,排查一下其他原因吧,例如网络、端口、登录权限等。

发表评论

表情:
评论列表 (有 0 条评论,230人围观)

还没有评论,来说两句吧...

相关阅读