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

很多人装了MySQL8.0,然后使用Navicat等客户端登录的时候报了以下错误:1251 - Client does not support authentication protocol requested by server;consider upgrading MySQL_第1张图片
原因
MySQL8.0使用新的密码验证插件caching_sha2_password,而MySQL8.0以下的,只要不是太旧的客户端,都是使用mysql_native_password验证插件,两个插件不兼容导致了登录异常

[root@mysql8 ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.12 MySQL Community Server - GPL

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show variables like 'default_authentication_plugin';
+-------------------------------+-----------------------+
| Variable_name                 | Value                 |
+-------------------------------+-----------------------+
| default_authentication_plugin | caching_sha2_password |
+-------------------------------+-----------------------+
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登录了,如果还有问题,排查一下其他原因吧,例如网络、端口、登录权限等。

你可能感兴趣的:(MySQL)