当在服务器上面安装好mysql并且启动之后,就可以在本地连接,输入要连接的服务器主机名与 端口(一般为3306),用户名与密码

第一次连接的时候,我的出现了“Client does not support authentication protocol requested by server,considering upgrading mysql client”问题,之后通过查找网上知道了原因是因为服务器上的mysql超过了8.mysql8之前的版本中加密规则是mysql_native_password,而在mysql8之后,加密规则是caching_sha2_password。
按照步骤
1.通过mysql -uroot -p进入mysql的命令行模式
2.输入命令修改相关机密方法
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;这里的password是你正在使用的密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';#更新一下用户的密码这里的password为你修改的新密码。
FLUSH PRIVILEGES; #刷新权限,使自己的修改生效。

这时还是连接不上,然后通过telnet3306数据库对应的接口,出现了8.0.11;S"3<VN,.Y\k4Ycaching_sha2_password这个信息,是修改没有生效还是其他原因?重启容器之后还是不行。
然后use mysql;
查询表中的相关信息 select user,host,plugin from user where user='root';

这时发现了问题,原理刚刚修改的是localhost,对于非本机的连接密码校验规则还是没有变。
alter user 'root'@'%' identified by 'password' password expire never;
alter user 'root'@'%' identified with mysql_native_password by 'why';//why是自己新修改的密码。
flush privileges;//再次刷新一下权限配置。
为了确定下,重新查一下,select user,host,plugin from user where user='root';

这样用navicat重新连接服务器mysql就可以了。
网友评论