1.问题描述
在虚拟机中,安装好LNMP环境之后,然后使用本地的navicat软件连接虚拟机的mysql时,出现【1251 - Client does not support authentication protocol requested by server; consider upgrading MySQL client】错误。
2.问题图解
3 问题解决
1) 首先,登录mysql容器,然后查看mysql信息,具体操作如下:
# 登录mysql容器
docker exec -it c_mysql /bin/bash
# 进入Mysql,密码是123456
mysql -u root -p
# 查看mysql信息
select host,user,plugin,authentication_string from mysql.user;
备注:host为 % 表示不限制ip,localhost表示本机使用,plugin为非mysqlnativepassword 则需要修改密码。
2) 接着,修改mysql密码,其具体操作如下:
mysql> use mysql;
mysql> alter user 'root'@'%' identified with mysql_native_password by '123456789';
mysql> flush privileges;
mysql> select host,user,plugin,authentication_string from mysql.user;
注意:从图中可以知道,有两个root用户,分别为第1个和第4个,这两个用户的区别主要看host处:%表示允许所有IP连接该mysql服务器,该root用户用于客户端连接虚拟机的mysql;而localhost表示在本地虚拟机中,若要连接docker的mysql,要使用该root账号。
3)接着,退出mysql容器,然后重启mysql容器:
docker restart c_mysql
4)到此,mysql设置完成!
4.问题验证