链接mysql
select host,user,plugin,authentication_string from mysql.user;
上网搜索解决方案,网上说出现这种情况的原因是:mysql8 之前的版本中加密规则是mysql_native_password,而在mysql8之后,加密规则是caching_sha2_password,
解决问题方法有两种:
方法1.升级navicat驱动;
方法2.把mysql用户登录密码加密规则还原成mysql_native_password.
这里采用方法2解决,具体操作步骤如下。
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
#更新user为root,host为% 的密码为123456
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
#更新user为root,host为localhost 的密码为123456
或
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER; #修改加密规则 (这行我没有写,不过貌似也可以)
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; #更新一下用户的密码
FLUSH PRIVILEGES; #刷新权限
···
打开[命令行](https://so.csdn.net/so/search?q=%E5%91%BD%E4%BB%A4%E8%A1%8C&spm=1001.2101.3001.7020)小黑屏,进入MySQL的bin目录,然后输入mysql -u root -p,输入密码,登录成功
执行SQL查询用户信息 再次查看权限
select host,user,plugin,authentication_string from mysql.user;