很多人装了MySQL8.0,然后使用Navicat等客户端登录的时候报了以下错误: 原因 MySQL8.0使用新的密码验证插件caching_sha2_password,而MySQL8.0以下的,只要不是太旧的客户端,都是使用mysql_native_password验证插件,两个插件不兼容导致了登录异常
1:用管理员身份进入cmd; [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 © 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.
2:查看插件 mysql> show variables like ‘default_authentication_plugin’;
解决: 将default_authentication_plugin设为mysql_native_password,并且以mysql_native_password插件方式更新一下用户密码,例如我登录使用的用户是root@’%’: 1.首先在my.cnf加入以下参数,并重启MySQL实例 default_authentication_plugin=mysql_native_password 2.更新登录用户密码 ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘(root的密码123456)’; ‘root’@’localhost’ 中的localhost就是host地址,%就是所有的了,123456就是Navicat中root的链接密码,网上大部分这里‘root’@’localhost’写的是‘root’@’%’,所有的标点符号都是英文; 成功后最后记得输入
FLUSH PRIVILEGES;
更改密码后需用flush privileges刷新MySQL的系统权限相关表,否则会出现拒绝访问,还有一种方法,就是重新启动mysql服务器,来使新设置生效。
此时就可以成功链接Navicat了。
