pc端Navicat连接aly服务器上Docker安装的MYSQL
在pc端,使用Navicat连接,阿里云服务器上面用Docker方式安装的Mysql数据库,连接时报错:
Client does not support authentication protocol requested by server;consider upgrading MySql client
网友对于错误的描述:(
在安装完MySQL的时候,我们现在一般都使用Navicat来连接数据库,可惜出现下面的错误:1251-Client does not support authentication protocol requested by server; consider upgrading MySQL client。出现上述问题的原因是:mysql8 之前的版本中加密规则是mysql_native_password,而在mysql8之后,加密规则是caching_sha2_password 把mysql用户登录密码加密规则还原成mysql_native_password
原文链接:https://blog.csdn.net/qq_38455201/java/article/details/83024357
)
解决方案:
①登录docker
# docker exec -ti mysql bash
②登录MySql
root@2d9e0f4d592a:/# mysql -h localhost -u root -p
输入数据库密码(docker安装mysql时,run启动docker时设置的密码:docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -d mysql)
③登录MYSQL数据库成功后,查看所有用户
mysql> SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;
④查看数据库
mysql> show databases;
⑤确认数据库登录成功即可,③④可省略,修改加密规则,因为最新版的加密规则好像不一样,安装的过程当中是有提示的:
mysql> ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘password’ PASSWORD EXPIRE NEVER;
(注意,password的单引号)
⑥修改用户的认证规则:
mysql> alter user '用户名'@'%' identified with mysql_native_password by '密码';
例如我的:alter user 'root'@'%' identified with mysql_native_password by '123456';
⑦刷新权限
mysql> flush privileges;
上述操作后,即可连接,连接效果如下: